1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: fix time.parse_iso8601(2037-07-23)?.add_days(181).str() == "1901-12-13 17:31:44"

This commit is contained in:
Delyan Angelov
2021-07-06 18:51:47 +03:00
parent 9f8c3cc159
commit 55eeb701a9
8 changed files with 29 additions and 16 deletions

13
vlib/time/Y2K38_test.v Normal file
View File

@@ -0,0 +1,13 @@
import time
fn test_time_after_2038_works() {
after_time := time.parse_iso8601('2037-07-23') or { time.now() }
dump(after_time)
error_time := after_time.add_days(180)
dump(error_time)
assert error_time.str() == '2038-01-19 00:00:00'
// NB: the next date is after Y2K38, it should NOT wrap:
error_time2 := after_time.add_days(181)
dump(error_time2)
assert error_time2.str() == '2038-01-20 00:00:00'
}