Handling dates when we switch to daylight savings time and back

前端 未结 3 2086
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 08:54

I would like to use R for time series analysis. I want to make a time-series model and use functions from the packages timeDate and forecast.

I have intraday data in

3条回答
  •  醉话见心
    2020-11-29 09:29

    Here is getting the daylight savings time offset - e.g. Central Daylight Savings time

    > Sys.time()
    

    "2015-08-20 07:10:38 CDT" # I am at America/Chicago daylight time

    > as.POSIXct(as.character(Sys.time()), tz="America/Chicago")
    

    "2015-08-20 07:13:12 CDT"

    > as.POSIXct(as.character(Sys.time()), tz="UTC") - as.POSIXct(as.character(Sys.time()), tz="America/Chicago")
    

    Time difference of -5 hours

    > as.integer(as.POSIXct(as.character(Sys.time()), tz="UTC") - as.POSIXct(as.character(Sys.time()), tz="America/Chicago"))
    

    -5

    Some inspiration was from

    Converting time zones in R: tips, tricks and pitfalls

提交回复
热议问题