确定日期是格林尼治标准时间还是BST

时间:2019-05-16 17:26:05

标签: r timezone

例如,我有一堆日期(以UTC为单位)

> dates <- as.POSIXct(c('2019-01-01', '2019-07-01', '2019-08-01'), tz = 'UTC')
> dates
[1] "2019-01-01 UTC" "2019-07-01 UTC" "2019-08-01 UTC"

我想知道向量中的每个日期是在格林尼治标准时间还是BST期间。

因此上述内容会给出

"GMT" "BST" "BST"

1 个答案:

答案 0 :(得分:0)

可能不是最好的方法,但是得到了我想要的

library(lubridate)
ifelse(hour(force_tz(as.POSIXct(as.Date(dates)), tz = 'Europe/London')) == 1, 'BST', 'GMT')
相关问题