I encountered a strange situation while converting time stamps between "America/Detroit" and "GMT". Upon closer inspection I discovered that R converted times between 1 and 2 am on the day daylight savings ends differently in 2010 and 2011. In 2010 it listed those times as being in "EDT" and in 2011 it listed those times in "EST". The result was that conversion to GMT added 4 hours in one case and 5 hours in the other. Can anyone she light on this situation and suggest a solution for correcting this inconsistency?
a = as.POSIXct("2010-11-07 01:58:00", tz = "America/Detroit")
#[1] "2010-11-07 01:58:00 EDT"
b = as.POSIXct("2011-11-06 01:58:00", tz = "America/Detroit")
# [1] "2011-11-06 01:58:00 EST"
format(c(a,b), tz = "GMT")
# [1] "2010-11-07 05:58:00" "2011-11-06 06:58:00"
The times that you give are ambiguous. As the clock is "fallen back" at 2, the local time 1:58 for these days occurs twice on each day, once in EDT and again in EST.
Both are correct, as you do not specify which you mean.
The OS library code for this will (probably) use an iterative algorithm, ending when the time_t
value derived agrees with the struct tm
value passed to mktime
. Because of this, the results will be essentially random.
Here's an example:
http://www.opensource.apple.com/source/ntp/ntp-13/ntp/libntp/mktime.c