Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone specs are not daylight savings independent #110

Closed
boshek opened this issue Oct 9, 2018 · 0 comments
Closed

Timezone specs are not daylight savings independent #110

boshek opened this issue Oct 9, 2018 · 0 comments
Assignees
Labels

Comments

@boshek
Copy link
Collaborator

boshek commented Oct 9, 2018

These timezones are not daylight savings independent:

library(tidyhydat)
unique(allstations$station_tz)
#>  [1] "America/Moncton"       "America/New_York"     
#>  [3] "America/Halifax"       "America/Glace_Bay"    
#>  [5] "America/Toronto"       "America/Thunder_Bay"  
#>  [7] "America/Goose_Bay"     "America/St_Johns"     
#>  [9] "America/Winnipeg"      "America/Edmonton"     
#> [11] "America/Regina"        "America/Atikokan"     
#> [13] "America/Rainy_River"   "America/Rankin_Inlet" 
#> [15] "America/Yellowknife"   "America/Vancouver"    
#> [17] "America/Dawson_Creek"  "America/Whitehorse"   
#> [19] "America/Creston"       "America/Dawson"       
#> [21] "America/Fort_Nelson"   "America/Inuvik"       
#> [23] "America/Cambridge_Bay" "America/Iqaluit"      
#> [25] "America/Resolute"      "America/Chicago"      
#> [27] "America/Detroit"       "America/Blanc-Sablon" 
#> [29] "America/Denver"        "America/Swift_Current"
#> [31] "America/Yakutat"       "America/Juneau"       
#> [33] "America/Sitka"         "America/Los_Angeles"  
#> [35] "America/Anchorage"     "America/Pangnirtung"

Rather they should labelled as:

grep("Etc", OlsonNames(), value = TRUE)
#>  [1] "Etc/GMT"       "Etc/GMT-0"     "Etc/GMT-1"     "Etc/GMT-10"   
#>  [5] "Etc/GMT-11"    "Etc/GMT-12"    "Etc/GMT-13"    "Etc/GMT-14"   
#>  [9] "Etc/GMT-2"     "Etc/GMT-3"     "Etc/GMT-4"     "Etc/GMT-5"    
#> [13] "Etc/GMT-6"     "Etc/GMT-7"     "Etc/GMT-8"     "Etc/GMT-9"    
#> [17] "Etc/GMT+0"     "Etc/GMT+1"     "Etc/GMT+10"    "Etc/GMT+11"   
#> [21] "Etc/GMT+12"    "Etc/GMT+2"     "Etc/GMT+3"     "Etc/GMT+4"    
#> [25] "Etc/GMT+5"     "Etc/GMT+6"     "Etc/GMT+7"     "Etc/GMT+8"    
#> [29] "Etc/GMT+9"     "Etc/GMT0"      "Etc/Greenwich" "Etc/UCT"      
#> [33] "Etc/Universal" "Etc/UTC"       "Etc/Zulu"

Created on 2018-10-09 by the reprex package (v0.2.1)

This could be done here:

allstations <- realtime_stations() %>%
mutate(HYD_STATUS = "ACTIVE", REAL_TIME = TRUE) %>%
bind_rows(hy_stations()) %>%
distinct(STATION_NUMBER, .keep_all = TRUE) %>%
select(STATION_NUMBER, STATION_NAME, PROV_TERR_STATE_LOC, HYD_STATUS, REAL_TIME, LATITUDE, LONGITUDE) %>%
mutate(station_tz = tz_lookup_coords(LATITUDE, LONGITUDE, method = "accurate")) %>%
mutate(standard_offset = map_dbl(station_tz, ~ {
gmt_offset = as.POSIXlt(as.POSIXct("2017-01-01 12:00:00", tz = .x))$gmtoff
if (is.null(gmt_offset)) gmt_offset <- 0
gmt_offset / 3600
})) %>%
write_csv("./data-raw/HYDAT_internal_data/allstations.csv")

@boshek boshek changed the title Timezone specs are not timezone independent Timezone specs are not daylight savings independent Oct 9, 2018
@boshek boshek added this to the tidyhydat 0.4.0 milestone Feb 2, 2019
@boshek boshek added the bug label Feb 2, 2019
@boshek boshek self-assigned this Feb 2, 2019
@boshek boshek closed this as completed in dae0fbc Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant