简体   繁体   English

as.Date()不尊重POSIXct时区

[英]as.Date() does not respect POSIXct time zones

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. 好吧所以这里是一个微妙的“怪癖”在r as.Date函数转换为带有时区的POSIXct,我想知道它是否是一个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? 愚人节?

The default time zone for as.Date.POSIXct is "UTC" (see the help page). as.Date.POSIXct的默认时区是"UTC" (请参阅帮助页面)。 Try as.Date(as.POSIXct("2013-04-01", tz = "Europe/London"),tz = "Europe/London") . 试试as.Date(as.POSIXct("2013-04-01", tz = "Europe/London"),tz = "Europe/London")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM