Skip to content

Instantly share code, notes, and snippets.

@thisisnic
Created September 12, 2023 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thisisnic/4faf93dced98411220a042b5bd4f43f5 to your computer and use it in GitHub Desktop.
Save thisisnic/4faf93dced98411220a042b5bd4f43f5 to your computer and use it in GitHub Desktop.
Detect legacy timezone symlinks in code (2023c-8 not 2023c-10)
# 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