Describe the bug
The epoch generation is considering timezone into account. This is inconsistent with the standard epoch implementation.
In linux, you can generate an epoch by date +%s command, and that generates an epoch that's independent of timezone.
Same with python's print(time.time()) method.
import time
println(time.now().unix_time())
Expected Behavior
time.now().unix_time() should generate the same value as Linux's date +%s command
Current Behavior
On a system that's on a different timezone than UTC, generate the epoch timestamp in V, and generate the unix timestamp in Linux. When you subtract one value from the other, you get a value that's the timezone difference in seconds.
Example:
Run this script on a machine that's in a different timezone than GMT
import time
import os
fn main() {
linux_epoch := os.execute("date +%s").output.trim(r'\s').i64()
v_epoch := time.now().unix_time()
diff := linux_epoch - v_epoch
println("linux_poch = ${linux_epoch} | v_epoch = ${v_epoch} | diff = ${diff}")
}
And you will get a value that is equal to the timezone difference in seconds
Reproduction Steps
Run this script on a machine that's in a different timezone than GMT
import time
import os
fn main() {
linux_epoch := os.execute("date +%s").output.trim(r'\s').i64()
v_epoch := time.now().unix_time()
diff := linux_epoch - v_epoch
println("linux_poch = ${linux_epoch} | v_epoch = ${v_epoch} | diff = ${diff}")
}
And you will get a value that is equal to the timezone difference in seconds
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.3.3 713c95f
Environment details (OS name and version, etc.)
MacOs Ventura M1
Describe the bug
The epoch generation is considering timezone into account. This is inconsistent with the standard epoch implementation.
In linux, you can generate an epoch by
date +%scommand, and that generates an epoch that's independent of timezone.Same with python's
print(time.time())method.Expected Behavior
time.now().unix_time()should generate the same value as Linux'sdate +%scommandCurrent Behavior
On a system that's on a different timezone than UTC, generate the epoch timestamp in V, and generate the unix timestamp in Linux. When you subtract one value from the other, you get a value that's the timezone difference in seconds.
Example:
Run this script on a machine that's in a different timezone than GMT
And you will get a value that is equal to the timezone difference in seconds
Reproduction Steps
Run this script on a machine that's in a different timezone than GMT
And you will get a value that is equal to the timezone difference in seconds
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.3.3 713c95f
Environment details (OS name and version, etc.)
MacOs Ventura M1