as.Date()不遵守POSIXct时区 [英] as.Date() does not respect POSIXct time zones
本文介绍了as.Date()不遵守POSIXct时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,这是r as.Date函数从带时区的POSIXct转换时的一个微妙的怪癖",我想知道这是否是一个错误.
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?
推荐答案
as.Date.POSIXct
的默认时区为"UTC"
(请参见帮助页面)).尝试 as.Date(as.POSIXct("2013-04-01",tz =欧洲/伦敦"),tz =欧洲/伦敦")
.
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")
.
这篇关于as.Date()不遵守POSIXct时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文