Search code examples
rstatisticsposixposixctdatetime-conversion

POSIXct: as.POSIXct("2008-03-30 02:00:00",format="%Y-%m-%d %H:%M:%S") fails is it a bug in R?


Very strange things happen while converting to POSIXct:

> as.POSIXct("2008-03-30 02:00:00",format="%Y-%m-%d %H:%M:%S")
[1] NA

but:

> as.POSIXct("2008-02-28 02:00:00",format="%Y-%m-%d %H:%M:%S")
[1] "2008-02-28 02:00:00 CET"

I am clueless. is it a bug in R? Does it perhaps have to do with my German (Berlin) locale? I am using R 2.14.2 for windows.


Solution

  • This is the beginning of daylight savings time in Germany in 2008, see this link. That time effectively is equivalent to "2008-03-30 03:00:00" (an hour later), which should work on your system. So, yes, this is related to your locale.