tests/testthat/test-floored.R

test_that("floored", {
  expect_true(dtt_floored(as.Date("2002-02-02"), "days"))
  expect_false(dtt_floored(as.Date("2002-02-02"), "months"))
  expect_false(dtt_floored(as.Date("2002-01-02"), "months"))
  expect_true(dtt_floored(as.Date("2002-02-01"), "months"))
  expect_true(dtt_floored(hms::as_hms("01:02:00"), "seconds"))
  expect_true(dtt_floored(hms::as_hms("01:20:00"), "minutes"))
  expect_false(dtt_floored(hms::as_hms("01:00:10"), "minutes"))
  expect_true(dtt_floored(as.POSIXct("2000-02-02", tz = "Etc/GMT+9"), "seconds"))
})

Try the dttr2 package in your browser

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

dttr2 documentation built on Sept. 19, 2021, 9:06 a.m.