rtimezone

Determine if a date is GMT or BST


I have a bunch of dates (in UTC) e.g.

> 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"

I want to know if each date in my vector is during GMT or BST.

So the above would give

"GMT" "BST" "BST"

Solution

  • Might not be the best way of doing it, but got what I wanted using

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