且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

xts 的每小时端点和夏令时

更新时间:2023-02-26 19:41:52

只是一种预感,但这可能是 TZ 的另一种表现形式以及从标准时间到夏令时的转换.尝试转换为 UTC,看看会发生什么.

Just a hunch but this may be yet another manifestation of TZ and a switch from standard time to daylight savings time. Try to convert to UTC and see what happens.

或者,将您的数据按一周(或一个月或……)移动,看看是否会出现同样的问题.

Alternatively, move your data by a week (or month or ...) and see if the same issue arises.

如果这就是问题所在.那么这并不是真正的错误,因为回退"之夜确实从凌晨 2:00 开始有两个小时.

And if that's the issue. then this is not really a bug as the 'fall back' night has indeed two hours starting at 02:00am.

虽然你没有说你的时区是什么,虽然它在我的(美国中部)不起作用,但我们可以展示这个问题欧洲大陆:

And while you didn't say what your timezone was, and while it doesn't work in mine (US Central), we can exhibit the issue for the European continent:

R> ISOdate(2007, 10, 28, 0, 30, 0, tz="Europe/Berlin") + seq(0,4)*60*60
[1] "2007-10-28 00:30:00 CEST" "2007-10-28 01:30:00 CEST"
[3] "2007-10-28 02:30:00 CEST" "2007-10-28 02:30:00 CET" 
[5] "2007-10-28 03:30:00 CET" 
R> 

看看如何

  1. TZ 属性从 CEST 切换到 CET

  1. the TZ attribute switches from CEST to CET

实际上有两个 02:30:00 小时,两个时区各一个.

there are in fact two 02:30:00 hours, one for each of the two timezones.

所以 xts 中没有错误,但是 功能数据.

So no bug in xts but a feature in the data.