|
52 | 52 |
|
53 | 53 | local function negate(this) |
54 | 54 | local ticks = this.ticks |
55 | | - if ticks == -9223372036854775808 then |
| 55 | + if ticks == (-9223372036854775807 - 1) then |
56 | 56 | throw(OverflowException("Overflow_NegateTwosCompNum")) |
57 | 57 | end |
58 | 58 | return TimeSpan(-ticks) |
@@ -138,7 +138,9 @@ local function parse(s) |
138 | 138 | end |
139 | 139 | end |
140 | 140 | if sign == '-' then |
141 | | - day, hour, minute, second, milliseconds = -day, -hour, -minute, -second, -milliseconds |
| 141 | + day, hour, minute, second, milliseconds = -tonumber(day), -tonumber(hour), -tonumber(minute), -tonumber(second), -tonumber(milliseconds) |
| 142 | + else |
| 143 | + day, hour, minute, second, milliseconds = tonumber(day), tonumber(hour), tonumber(minute), tonumber(second), tonumber(milliseconds) |
142 | 144 | end |
143 | 145 | return TimeSpan(day, hour, minute, second, milliseconds) |
144 | 146 | end |
@@ -223,7 +225,7 @@ TimeSpan = System.defStc("System.TimeSpan", { |
223 | 225 | Subtract = subtract, |
224 | 226 | Duration = function (this) |
225 | 227 | local ticks = this.ticks |
226 | | - if ticks == -9223372036854775808 then |
| 228 | + if ticks == (-9223372036854775807 - 1) then |
227 | 229 | throw(OverflowException("Overflow_Duration")) |
228 | 230 | end |
229 | 231 | return TimeSpan(ticks >= 0 and ticks or - ticks) |
@@ -297,4 +299,4 @@ TimeSpan = System.defStc("System.TimeSpan", { |
297 | 299 | zero = TimeSpan(0) |
298 | 300 | TimeSpan.Zero = zero |
299 | 301 | TimeSpan.MaxValue = TimeSpan(9223372036854775807) |
300 | | -TimeSpan.MinValue = TimeSpan(-9223372036854775808) |
| 302 | +TimeSpan.MinValue = TimeSpan((-9223372036854775807 - 1)) |
0 commit comments