I have time series data obtained from a data logger that was set in one time zone without daylight saving ( NZST or UTC + 12: 00), and the data spans several years. Data loggers do not account for DST changes and are synchronized with local time with / without DST (depending on who deployed it).
However, when I receive data in R, I cannot use as.POSIXct correctly to ignore DST. I am using R 2.14.0 on a Windows computer with these settings:
> Sys.timezone() [1] "NZDT" > Sys.getlocale("LC_TIME") [1] "English_New Zealand.1252"
Here are three timestamps for changing spring DST, each of which is one hour apart:
> ts_str <- c("28/09/2008 01:00", "28/09/2008 02:00", "28/09/2008 03:00") > as.POSIXct(ts_str, format="%d/%m/%Y %H:%M", tz="") [1] "2008-09-28 01:00:00 NZST" NA [3] "2008-09-28 03:00:00 NZDT" > as.POSIXct(ts_str, format="%d/%m/%Y %H:%M", tz="UTC") [1] "2008-09-28 01:00:00 UTC" "2008-09-28 02:00:00 UTC" [3] "2008-09-28 03:00:00 UTC"
As you can see, the clock jumped forward from 1:59 to 3:00, so 2:00 is not valid, therefore NA. Alternatively, I can use tz="UTC" to ignore DST changes. However, I would prefer to keep the correct time zone, since I have other series of data recorded using DST (NZDT or UTC + 13: 00) that I would like to add (via merge ) for my analysis.
How to configure tz parameter on MS Windows computer? I tried a lot of things like “NZST”, “New Zealand Standard Time”, “UTC + 12: 00”, “+1200”, etc., but no luck. Or can I change some other settings?
Mike t
source share