0

I stubbled across what appears to be a odd error in the as.POSXct function in R associated with date/time of 2 am on March 9, 2014.

The following simple example shows the nature of the bug.

3 am works

> as.POSIXct("2014-Mar-09 03:00", format="%Y-%b-%d %H:%M")
[1] "2014-03-09 03:01:00 MDT"

2 am fails

> as.POSIXct("2014-Mar-09 02:00", format="%Y-%b-%d %H:%M")
[1] NA

Any time within 2 am fails

> as.POSIXct("2014-Mar-09 02:01", format="%Y-%b-%d %H:%M")
[1] NA
> as.POSIXct("2014-Mar-09 02:59", format="%Y-%b-%d %H:%M")
[1] NA

March 10, 2014 is fine

> as.POSIXct("2014-Mar-10 02:00", format="%Y-%b-%d %H:%M")
[1] "2014-03-10 02:00:00 PDT"

The original conversions specified the timezone (tz='Canada/Mountain'), which has been excluded for brevity. The same results were observed. Adding non-existing seconds or changing the format (example %I for 12 hr time) didn't work either.

What is going on? This is for R version 3.2.3 (OS X).

Rider_X
  • 101
  • 2
  • 1
    Try Googling "daylight savings time 2014". Those moments in time....NEVER HAPPENED! Duh duh duh! – joran Apr 11 '16 at 17:32
  • Thanks to daylight savings time, some times simply do not exist. – MrFlick Apr 11 '16 at 17:32
  • @joran - paste your comment as an answer I will accept it. I am befuddled why "professional" software is adding no-existing times to the log files – Rider_X Apr 11 '16 at 17:34
  • My general impression is that folks who write software that is heavily time/date dependent would say that it's sort of a miracle that dates/times work correctly on computers at all. – joran Apr 11 '16 at 17:37
  • @joran - that's setting the bar rather low! – Rider_X Apr 11 '16 at 17:40
  • @MrFlick - I missed that duplicate question in my quick search, thank you for finding that existing thread. – Rider_X Apr 11 '16 at 17:41
  • I just mean that I have gathered that correctly implementing software to deal with dates/times in literally all cases becomes so unimaginably complex that it's sort of a miracle that even simple things work. – joran Apr 11 '16 at 17:45

0 Answers0