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

time: turn Time.unix to i64, so it can represent times before 1970-01-01, fix time operators, add more tests (#11050)

This commit is contained in:
Delyan Angelov
2021-08-04 13:12:02 +03:00
committed by GitHub
parent 1bf6d04e37
commit efa8dcf4d2
15 changed files with 107 additions and 40 deletions

View File

@ -0,0 +1,33 @@
import time
fn test_add_to_day_in_the_previous_century() ? {
a := time.parse_iso8601('1900-01-01') ?
aa := a.add_days(180)
dump(a.debug())
dump(aa.debug())
assert aa.ymmdd() == '1900-06-29'
}
fn test_add_to_day_in_the_past() ? {
a := time.parse_iso8601('1990-03-01') ?
aa := a.add_days(180)
assert aa.ymmdd() == '1990-08-27'
}
fn test_add_to_day_in_the_recent_past() ? {
a := time.parse_iso8601('2021-03-01') ?
aa := a.add_days(180)
assert aa.ymmdd() == '2021-08-28'
}
fn test_add_to_day_in_the_future_1() ? {
a := time.parse_iso8601('3000-11-01') ?
aa := a.add_days(180)
assert aa.ymmdd() == '3001-04-30'
}
fn test_add_to_day_in_the_future_2() ? {
a := time.parse_iso8601('3000-12-30') ?
aa := a.add_days(180)
assert aa.ymmdd() == '3001-06-28'
}