tests/testthat/test-am-pm.R

test_that("am and pm correctly identify time of day", {
  x <- as.POSIXct(c("2009-08-03 13:01:59", "2008-08-03 10:01:59"), tz = "UTC")
  expect_equal(am(x), c(FALSE, TRUE))
  expect_equal(pm(x), c(TRUE, FALSE))
})

test_that("am and pm handle various classes of date-time object", {
  x <- as.POSIXct(c("2009-08-03 13:01:59", "2008-08-03 10:01:59"), tz = "UTC")
  expect_equal(am(x), c(FALSE, TRUE))
  expect_equal(am(as.POSIXlt(x)), c(FALSE, TRUE))
  expect_equal(am(as.Date(x)), c(TRUE, TRUE))
})
hadley/lubridate documentation built on Feb. 3, 2024, 9:37 a.m.