I have a problem converting POSIXct to character and back in POSIXct in R. I run the following code:
time_seq_01 <- seq(as.POSIXct(\"2012-10-28 02:00:00\"
Here's a work around that goes from POSIXct
to character
back to POSIXct
preserving the original daylight savings time status.
Sys.setenv(TZ='Europe/Berlin') # to reproduce OP's example
time_seq_01 <- seq(as.POSIXct("2012-10-28 02:00:00"), by = 900, length.out = 10)
time_seq_02 <- format(time_seq_01,usetz = TRUE)
time_seq_02_lt <- as.POSIXlt(time_seq_02)
time_seq_02_lt$isdst <- as.POSIXlt(time_seq_01)$isdst
time_seq_03 <- as.POSIXct(time_seq_02_lt)
As far as I can tell, R's support for string-to-datetime doesn't include DST flags specified within the strings.