Skip to content

Instantly share code, notes, and snippets.

@Dmitrii-I
Created May 2, 2017 17:50
Show Gist options
  • Save Dmitrii-I/fe5f3d2c473f949cd3c95f63c30d06e7 to your computer and use it in GitHub Desktop.
Save Dmitrii-I/fe5f3d2c473f949cd3c95f63c30d06e7 to your computer and use it in GitHub Desktop.
Weird timezone behavior POSIXct objects in R
cat('Weird timezone behavior')
# Weird timezone behavior
(t1 <- as.POSIXct(c('2015-02-01 20:00', '2015-10-25 02:57'))) # CET CET
# [1] "2015-02-01 20:00:00 CET" "2015-10-25 02:57:00 CET"
(t2 <- as.POSIXct(c('2015-06-01 20:00', '2015-10-25 02:57'))) # CEST CEST
# [1] "2015-06-01 20:00:00 CEST" "2015-10-25 02:57:00 CEST"
(t3 <- as.POSIXct('2015-10-25 02:57')) # CEST
# [1] "2015-10-25 02:57:00 CEST"
t1[2] == t2[2]
# [1] FALSE
(t2 <- as.POSIXct(c('2015-06-01 20:00', '2015-10-25 02:57'))) # CEST CEST
# [1] "2015-06-01 20:00:00 CEST" "2015-10-25 02:57:00 CEST"
(t1 <- as.POSIXct(c('2015-02-01 20:00', '2015-10-25 02:57'))) # CET CET
# [1] "2015-02-01 20:00:00 CET" "2015-10-25 02:57:00 CET"
(t3 <- as.POSIXct('2015-10-25 02:57')) # CET
# [1] "2015-10-25 02:57:00 CET"
t1[2] == t2[2]
# [1] FALSE
t1[2] == t3
# [1] TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment