0
假设我们有这三个日期:更改在照顾DST的XTS时区(夏令时间)
original_dates<- c("2015-12-31T07:00:00", "2015-12-31T08:00:00", "2015-12-31T09:00:00")
这个载体:
vector<- c("a", "b", "c")
我们转换日期POSIXct格式:
original_dates2<- as.POSIXct(original_dates, format="%Y-%m-%dT%H", tz = "GMT")
,并建立一个XTS:
my_xts<- xts(vector, order.by = original_dates2, frequency = "hourly")
所以我们有以下XTS对象:
> my_xts
[,1]
2015-12-31 07:00:00 "a"
2015-12-31 08:00:00 "b"
2015-12-31 09:00:00 "c"
Warning message:
timezone of object (GMT) is different than current timezone().
如果我想更改为当地时间我会改变时区:
indexTZ(my_xts)<- "America/Los_Angeles"
,但是这会产生一个错误的结果,因为我知道2015-12-31 07:00:00 GMT应该等于2015-12-31 00:00:00洛杉矶时间(即7小时。之前),不二零一五年十二月三十日23时00分00秒(即8小时。前)
> my_xts
[,1]
2015-12-30 23:00:00 "a"
2015-12-31 00:00:00 "b"
2015-12-31 01:00:00 "c"
Warning message:
timezone of object (America/Los_Angeles) is different than current timezone().
我想这是因为该时区转化indexTZ(my_xts)<- "America/Los_Angeles"
不考虑日光节约时间(DST),如图所示由DST功能:
> dst(my_xts)
[1] FALSE FALSE FALSE
的问题是,我如何改变使得DST被照顾的时区?
更多细节:
> Sys.timezone()
[1] "Europe/Paris"
> R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
version.string R version 3.3.1 (2016-06-21)