tests/testthat/helper-in-time-zone.R

inTimeZone <- function(tz, code) {
  previous_tz <- currentTimeZone()
  tryCatch({
    Sys.setenv(TZ=tz)
    eval(code)
  }, finally={
    Sys.setenv(TZ=previous_tz)
  })
}

currentTimeZone <- function() {
  Sys.getenv("TZ", Sys.timezone())
}
ankane/dbx documentation built on May 18, 2024, 8:31 a.m.