防范意外时区转换 [英] Guard against accidental time-zone conversion
问题描述
在R中,我有一堆在GMT测量的日期时间值。我不断发生事故,一些功能或另一个失去了我的价值观的时区,甚至失去了类名。即使是基本的功能,如 c()
和 unlist()
:
In R, I have a bunch of datetime values that I measure in GMT. I keep running into accidents where some function or another loses the timezone on my values, or even loses the class name. Even on functions so basic as c()
and unlist()
:
> dput(x)
structure(1317830532, class = c("POSIXct", "POSIXt"), tzone = "GMT")
> dput(c(x))
structure(1317830532, class = c("POSIXct", "POSIXt"))
> dput(list(x))
list(structure(1317830532, class = c("POSIXct", "POSIXt"), tzone = "GMT"))
> dput(unlist(list(x)))
1317830532
我觉得我是如果发生这种情况,我最不希望有一个真正的火星气候轨道器它。任何人都有任何策略来确保他们的日期保持投入?
I feel like I'm a hair's breadth away from having a real Mars Climate Orbiter moment if this happens when I least expect it. Anyone have any strategies for making sure their dates "stay put"?
推荐答案
为什么不将您的时区设置为GMT , 然后?如果某些东西被转换为当前时区,它仍然是正确的。
Why not set your timezone to GMT for your R sessions, then? If something gets converted to the "current" timezone, it is still right.
这篇关于防范意外时区转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!