Commit 1850de9
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 51ad319 commit 1850de9
2 files changed
Lines changed: 25 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2143 | 2143 | | |
2144 | 2144 | | |
2145 | 2145 | | |
2146 | | - | |
2147 | 2146 | | |
2148 | 2147 | | |
2149 | | - | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
2150 | 2151 | | |
2151 | 2152 | | |
| 2153 | + | |
2152 | 2154 | | |
2153 | | - | |
2154 | | - | |
2155 | | - | |
| 2155 | + | |
2156 | 2156 | | |
2157 | | - | |
2158 | | - | |
2159 | | - | |
| 2157 | + | |
2160 | 2158 | | |
2161 | | - | |
2162 | | - | |
2163 | | - | |
| 2159 | + | |
2164 | 2160 | | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
| 2161 | + | |
2168 | 2162 | | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
| 2163 | + | |
| 2164 | + | |
2174 | 2165 | | |
2175 | 2166 | | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | 2167 | | |
2183 | 2168 | | |
2184 | 2169 | | |
2185 | 2170 | | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
2186 | 2179 | | |
2187 | 2180 | | |
2188 | 2181 | | |
| |||
| 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