[R] unwanted switch to DST with POSIXct objects

Denis Chabot chabot.denis at gmail.com
Sun Jun 5 16:21:46 CEST 2011


Hi,

For a project I try to keep everything in normal time, not daylight saving time, to prevent problem when instruments collected data during the nights when we go from DST to normal time.

But sometimes R tricks me and I do not know how to prevent it.

This is one example:

lights_on = as.POSIXct(c("2011-05-06 04:09:26", "2011-05-07 04:07:53", "2011-05-08 04:06:21",
"2011-05-09 04:04:51", "2011-05-10 04:03:22", "2011-05-11 04:01:55",
"2011-05-12 04:00:30", "2011-05-13 03:59:06", "2011-05-14 03:57:45",
"2011-05-15 03:56:25", "2011-05-16 03:55:07"), tz="EST") # not DST

lights_off = as.POSIXct(c("2011-05-05 18:56:54", "2011-05-06 18:58:19", "2011-05-07 18:59:44",
"2011-05-08 19:01:08", "2011-05-09 19:02:32", "2011-05-10 19:03:55",
"2011-05-11 19:05:18", "2011-05-12 19:06:40", "2011-05-13 19:08:01",
"2011-05-14 19:09:22", "2011-05-15 19:10:42" ), tz="EST")	# not DST

(a = lights_on[c(1,5)])	# not DST
[1] "2011-05-06 04:09:26 EST" "2011-05-10 04:03:22 EST"

(b = lights_off[c(2,6)])	# not DST
[1] "2011-05-06 18:58:19 EST" "2011-05-10 19:03:55 EST"

(x = c(lights_off[2], lights_on[2])) # suddenly DST
[1] "2011-05-06 19:58:19 EDT" "2011-05-07 05:07:53 EDT"

Why did x end up in DST? How could I prevent it?

Thanks in advance,

Denis


More information about the R-help mailing list