Home > Software engineering >  time offset from UTC to local time
time offset from UTC to local time

Time:01-16

I would like to know the time offset from UTC to local time on a particular day (eventually for all days in 2019) for all time zones in the world.

I tried the following code in R but it did not work:

library(lutz)

time_zones <- OlsonNames()

for (tz in time_zones) {
  temp <- rbind(
    tz_offset("2019-01-01", tz = tz),
  )
}

Any suggestions on how to achieve this?

CodePudding user response:

library(lutz)

time_zones <- OlsonNames()

temp <- list()
for (tz in time_zones) {
  temp[[tz]] <- tz_offset("2019-01-01", tz = tz)
}

temp <- do.call(rbind, temp)
head(temp)
#                              tz_name           date_time zone is_dst utc_offset_h
#Africa/Abidjan         Africa/Abidjan 2019-01-01 00:00:00  GMT  FALSE            0
#Africa/Accra             Africa/Accra 2019-01-01 00:00:00  GMT  FALSE            0
#Africa/Addis_Ababa Africa/Addis_Ababa 2018-12-31 21:00:00  EAT  FALSE            3
#Africa/Algiers         Africa/Algiers 2018-12-31 23:00:00  CET  FALSE            1
#Africa/Asmara           Africa/Asmara 2018-12-31 21:00:00  EAT  FALSE            3
#Africa/Asmera           Africa/Asmera 2018-12-31 21:00:00  EAT  FALSE            3
  • Related