【问题标题】:R adding month over DST with lubridate gives unexpected resultR 用 lubridate 在 DST 上添加月份会产生意想不到的结果
【发布时间】:2019-03-12 22:17:33
【问题描述】:

在 DST 期间添加一个月时,我得到了意想不到的结果。我预计结果是“2018-11-01 GMT”。当我在 Windows 上运行此代码时,我得到了正确的结果,但是当我在 Red Hat Server 上运行相同的东西时,月份没有添加,见下文。

> d = as.POSIXct('2018-10-01 00:00:00', tz = 'Europe/London')
> d + months(1)
[1] "2018-10-01 BST"

有人知道发生了什么吗?

【问题讨论】:

    标签: r datetime dst lubridate


    【解决方案1】:

    使用 lubridate 的 %m+% 解决了这个问题

    > d %m+% months(1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-05
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 2017-03-19
      • 2021-10-04
      • 1970-01-01
      相关资源
      最近更新 更多