Created
September 12, 2023 07:32
-
-
Save thisisnic/4faf93dced98411220a042b5bd4f43f5 to your computer and use it in GitHub Desktop.
Detect legacy timezone symlinks in code (2023c-8 not 2023c-10)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detect invalid timezones | |
all_names <- tzdb::tzdb_names() | |
bad_names <- c( | |
all_names[startsWith(all_names, "US/")], | |
all_names[!stringr::str_detect(all_names, "/")] | |
) | |
all_names[map_lgl(all_names, ~!.x %in% bad_names)] | |
code_files <- list.files("R", full.names = TRUE) | |
test_files <- list.files("tests/testthat/", full.names = TRUE, pattern = ".R") | |
for(name in bad_names){ | |
cat(paste("\n", name, "\n")) | |
for(file_path in c(code_files, test_files)){ | |
x <- grep(paste0('"',name,'"'), readLines(file_path), value = TRUE) | |
if(length(x) > 0){ | |
cat(">>>", file_path, "\n") | |
cat(x, fill = TRUE) | |
cat("\n") | |
} | |
} | |
cat("\n") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment