Commit 5608e49
committed
Fix calendar:system_time_to_universal_time/2 input validation and negative rounding
Validate argv[0] is an integer before calling term_maybe_unbox_int64 to
prevent interpreting arbitrary term data as an int64.
Use floor division instead of C truncation for all time-unit branches so
negative sub-second values round toward negative infinity, matching OTP
semantics. For example calendar:system_time_to_universal_time(-1,
millisecond) now correctly returns {{1969,12,31},{23,59,59}}.
Add tests for negative calendar conversions and non-integer input.
Signed-off-by: Peter M <petermm@gmail.com>1 parent 261b6ef commit 5608e49
2 files changed
Lines changed: 25 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2055 | 2055 | | |
2056 | 2056 | | |
2057 | 2057 | | |
2058 | | - | |
2059 | 2058 | | |
2060 | 2059 | | |
2061 | | - | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
2062 | 2063 | | |
2063 | 2064 | | |
| 2065 | + | |
2064 | 2066 | | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
| 2067 | + | |
2068 | 2068 | | |
2069 | | - | |
2070 | | - | |
2071 | | - | |
| 2069 | + | |
2072 | 2070 | | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
| 2071 | + | |
2076 | 2072 | | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
| 2073 | + | |
2080 | 2074 | | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
| 2075 | + | |
| 2076 | + | |
2086 | 2077 | | |
2087 | 2078 | | |
2088 | | - | |
2089 | | - | |
2090 | | - | |
2091 | | - | |
2092 | | - | |
2093 | | - | |
2094 | 2079 | | |
2095 | 2080 | | |
2096 | 2081 | | |
2097 | 2082 | | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
2098 | 2091 | | |
2099 | 2092 | | |
2100 | 2093 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| |||
0 commit comments