KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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"), by = 900, length.out = 10) time_seq_02 <- as.character(time_seq_01) time_seq_03 <- as.POSIXct(time_seq_02) or equivalent: 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_03 <- as.POSIXct(time_seq_02) This are the timestamps in 2012 when the daylight saving transition from Central European Summer Time (CEST) to Central European Time (CET) occurs (Last Sunday in October 02:00 - 03:00). When I call these elements I get time_seq_01 [1] "2012-10-28 02:00:00 CEST" "2012-10-28 02:15:00 CEST" [3] "2012-10-28 02:30:00 CEST" "2012-10-28 02:45:00 CEST" [5] "2012-10-28 02:00:00 CET" "2012-10-28 02:15:00 CET" [7] "2012-10-28 02:30:00 CET" "2012-10-28 02:45:00 CET" [9] "2012-10-28 03:00:00 CET" "2012-10-28 03:15:00 CET" time_seq_02 [1] "2012-10-28 02:00:00 CEST" "2012-10-28 02:15:00 CEST" [3] "2012-10-28 02:30:00 CEST" "2012-10-28 02:45:00 CEST" [5] "2012-10-28 02:00:00 CET" "2012-10-28 02:15:00 CET" [7] "2012-10-28 02:30:00 CET" "2012-10-28 02:45:00 CET" [9] "2012-10-28 03:00:00 CET" "2012-10-28 03:15:00 CET" time_seq_03 [1] "2012-10-28 02:00:00 CEST" "2012-10-28 02:15:00 CEST" [3] "2012-10-28 02:30:00 CEST" "2012-10-28 02:45:00 CET" [5] "2012-10-28 02:00:00 CEST" "2012-10-28 02:15:00 CEST" [7] "2012-10-28 02:30:00 CEST" "2012-10-28 02:45:00 CET" [9] "2012-10-28 03:00:00 CET" "2012-10-28 03:15:00 CET" The creation of a POSIXct sequence does work correctly ( time_seq_01 ) the transition to character also ( time_seq_02 ). However the transition back from character back to POSIXct produces wrong timezone (CET/CEST) values ( time_seq_03</
Tags (comma-separated)
Save Edits
Cancel