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

time: fix repetitive time.now().local().local().local() offsetting the time further and further (#13861)

This commit is contained in:
Vincenzo Palazzo
2022-03-31 23:11:17 +02:00
committed by GitHub
parent 9c1981a309
commit 02c80bd445
5 changed files with 21 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ pub:
second int
microsecond int
unix i64
is_local bool // used to make time.now().local().local() == time.now().local()
}
// FormatDelimiter contains different time formats.
@@ -348,7 +349,7 @@ pub fn (d Duration) str() string {
// offset returns time zone UTC offset in seconds.
pub fn offset() int {
t := now()
t := utc()
local := t.local()
return int(local.unix - t.unix)
}