tests/testthat/test-tzone.R

context("tzone")

test_that("tzone", {
  expect_error(check_tzone(Sys.Date()), 
               "Sys.Date[(][)] time zone must be 'UTC' [(]not 'NULL'[)]")
  expect_error(check_tzone(Sys.time()), 
               "Sys.time[(][)] time zone must be 'UTC' [(]not 'NULL'[)]")
  x <- as.POSIXct("2000-01-02 03:04:55", tz = "Etc/GMT+8")
  expect_error(check_tzone(x, tzone = "PST8PDT"), 
               "x time zone must be 'PST8PDT' [(]not 'Etc[/]GMT[+]8'[)]")
  expect_identical(check_tzone(x, tzone = "Etc/GMT+8"), x)
})

Try the checkr package in your browser

Any scripts or data that you put into this service are public.

checkr documentation built on May 1, 2019, 6:59 p.m.