7

Okay so here is a subtle "quirk" in the r as.Date function converting from a POSIXct with a timezone, which I am wondering if it is a bug.

> as.POSIXct("2013-03-29", tz = "Europe/London")
[1] "2013-03-29 GMT"
> as.Date(as.POSIXct("2013-03-29", tz = "Europe/London"))
[1] "2013-03-29"

So far no problem, but.....

> as.POSIXct("2013-04-01", tz = "Europe/London")
[1] "2013-04-01 BST"
> as.Date(as.POSIXct("2013-04-01", tz = "Europe/London"))
[1] "2013-03-31"

Anybody seen this? Is this a bug or another quirk? April fools?

Blue Magister
  • 13,044
  • 5
  • 38
  • 56
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121

1 Answers1

8

The default time zone for as.Date.POSIXct is "UTC" (see the help page). Try as.Date(as.POSIXct("2013-04-01", tz = "Europe/London"),tz = "Europe/London").

Roland
  • 127,288
  • 10
  • 191
  • 288