In order to learn Flux I installed the latest build of the Flux REPL app (0.104.0). According to the Flux docs, now() should return UTC and system.time() should be the local time. I am running Ubuntu 20.10 and should have the time setup properly but both now() and system.time() report UTC time.
Here is peek of the Ubuntu time details and the Flux output, anyone with an idea of what I am doing wrong?
sillygoose@u-desktop:~/projects/flux$ timedatectl
Local time: Wed 2021-02-03 16:21:32 EST
Universal time: Wed 2021-02-03 21:21:32 UTC
RTC time: Wed 2021-02-03 21:21:33
Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
sillygoose@u-desktop:~/projects/flux$ ./flux repl
> import "system"
> system.time()
2021-02-03T21:21:59.589535036Z
> now()
2021-02-03T21:22:03.637864430Z
>
sillygoose@u-desktop:~/projects/flux$ ```
@sillygoose, I’ll have to test, but the docs may be incorrect when they say system.time() typically accounts for the local time zone. They may only return UTC.
The key difference between system.time() and now() is that now()should return the time the Flux script is executed (or in the cast of Flux tasks, when the task was supposed to be executed). Using now() multiple times in a script/query should return the same time value. system.time() returns the time the function itself is executed. So if using system.time() multiple times in a script/query, each execution of the system.time() function returns a different time value.
Thanks for confirming what I observed but I see there are actually two potential problems based on the problem report you reference:
now() does not have identical times in a script as documented (not cached)
system.time() does not return the machine local time
What is not clear in the problem report is that the documentation is right and system.time() should be a local time. I’ll add a comment there to see if this behavior can be clarified (I ran info this when trying to calculate my local time difference from UTC and the result was zero).
From the 2.0 docs (bold is mine):
now() returns the current UTC time. now() is cached at runtime, so all instances of now() in a Flux script return the same value.
system.time() returns the current system time of the host machine, which typically accounts for the local time zone. This time represents the time at which system.time() it is executed, so each instance of system.time() in a Flux script returns a unique value.