I am trying to convert a unix epoch timestamps to a date-time object using as.POSIXct()
I need to specify timezones (either Europe/London or UTC) when I call as.POSI
I am having a similar issue on macOS High Sierra 10.13.1. As soon as, I try to do anything with dates, I get the following error.
> as.POSIXct("2017-10-01", format = "%Y-%m-%d")
[1] "2017-10-01 GMT"
Warning message:
In strptime(x, format, tz = tz) :
unknown timezone 'zone/tz/2017c.1.0/zoneinfo/Pacific/Auckland'
The warning goes away if I set the environment variable to my timezone and I get the date back with the correct timezone.
> Sys.setenv(TZ = "Pacific/Auckland")
> as.POSIXct("2017-10-01")
[1] "2017-10-01 NZDT"
So, I have been setting the environment variable every time I need to do something to do with dates.
However, I have found this link talking about the same thing. Peter Dalgaard from R Core Team has replied saying this was a bug in macOS 10.13 Beta and that it is up to Apple to sort it out.
I am thinking to put Sys.setenv(TZ = "Pacific/Auckland") into .Rprofile so that it sets the time zone every time I start RStudio. I hope this helps.
Here is a link that might be useful if you want to try the .Rprofile approach I mentioned.
Update: It seems like this has been resolved in R 3.4.3. You can read more about it in the R news. Below is the related part of the release notes.
INSTALLATION on a UNIX-ALIKE
A workaround has been added for the changes in location of time-zone files in macOS 10.13 'High Sierra' and again in 10.13.1, so the default time zone is deduced correctly from the system setting when R is configured with --with-internal-tzcode (the default on macOS).
I can confirm that the new version of R resolves the issues with date/time objects.
> Sys.timezone()
[1] "Pacific/Auckland"
> Sys.time()
[1] "2017-12-30 16:22:32 NZDT"