When I run now() in lubridate I get this error.
Warning: Your system is mis-configured: ‘/etc/localtime’ is not a symlink Warning: It is strongly recommended to set environment variable TZ (time zone) to ‘Etc/Universal’ (or equivalent)
Then I get the current time tuned to UTC.
[1] "2019-04-14 15:50:18 UTC"
I've looked around for this on SO and github and I'm not finding much content. I'm running RStudio Server on a Linux box on EC2.
Here is the top of the output from sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2018.03
I looked for the timezone options in /usr/share/zoneinfo/ and saw Pacific which matches up with my timezone. I ran Sys.setenv(TZ='Pacific'), but it still serves the wrong time.
[1] "2019-04-14 16:15:04 Pacific"
Warning message:
In with_tz(Sys.time(), tzone) : Unrecognized time zone ''
We need more information to help you -- "on a Linux box" is not all that specific.
Looking at the function in question we see
R> lubridate::now
function (tzone = "")
with_tz(Sys.time(), tzone)
<bytecode: 0x55fd86dd68a8>
<environment: namespace:lubridate>
R>
so a base R call of Sys.time() coupled with some package-specific code to get to the timezone.
Now, how timezone information, something somewhat specific to the local installation, is provided to R is not standardized. Hence the error message.
I needed it once for another package (of mine) and R (at the time) was not doing enough -- so see
R> gettz::gettz()
[1] "America/Chicago"
R>
R has since improved and added a very similar heuristic (of looking in other possible places) so it is more robust. So please test some more and tell if R knows the timezone even if lubridate does not.
In either case, you could (should ?) set it to help the system.
And if R finds it, why not just use base R?
R> format(Sys.time(), "%F %T %Z")
[1] "2019-04-14 11:06:54 CDT"
R>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With