【发布时间】:2019-01-25 16:32:02
【问题描述】:
我在时间转换中缺少什么吗?很简单的例子:
library(lubridate)
time <- "2019-01-14 10:58:23.438000"
op <- options(digits.secs=6)
ymd_hms(time, tz = "Europe/Helsinki")
[1] "2019-01-14 10:58:23.437 EET"
ymd_hms(time)
[1] "2019-01-14 10:58:23.437 UTC"
为什么这里是毫秒一?似乎不是四舍五入的问题?
虽然这似乎可行:
time <- "2019-01-14 10:58:23.123456"
op <- options(digits.secs=6)
ymd_hms(time)
[1] "2019-01-14 10:58:23.123456 UTC"
会话信息
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Finnish_Finland.1252 LC_CTYPE=Finnish_Finland.1252 LC_MONETARY=Finnish_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=Finnish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.7.4
loaded via a namespace (and not attached):
[1] compiler_3.5.1 magrittr_1.5 tools_3.5.1 yaml_2.2.0 Rcpp_1.0.0 stringi_1.2.4 stringr_1.3.1
【问题讨论】:
-
在我的机器上运行你的代码(我也有
lubridate的 1.7.4 版)甚至不会输出毫秒数。我只得到:"2019-01-14 10:58:23 EET"和"2019-01-14 10:58:23 UTC"。 -
我添加了选项部分,我可能在运行之前更改了它。
-
好的,现在我得到了和你一样的输出。