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

View File

@@ -137,7 +137,7 @@ pub fn utc() Time {
// in this API call
t := C.time(0)
_ = C.time(&t)
return unix2(int(t), 0)
return unix2(i64(t), 0)
}
// smonth returns month name.
@@ -186,7 +186,7 @@ pub fn (t Time) add(d Duration) Time {
microseconds := i64(t.unix) * 1000 * 1000 + t.microsecond + d.microseconds()
unix := microseconds / (1000 * 1000)
micro := microseconds % (1000 * 1000)
return unix2(int(unix), int(micro))
return unix2(unix, int(micro))
}
// add_seconds returns a new time struct with an added number of seconds.