d <- as_messydate(c("2001-01-01", "2001-01", "2001", "2001-01-01..2001-02-02", "{2001-10-01,2001-10-04}", "{2001-01,2001-02-02}", "-2000-01-01", "2001-XX-01")) dd <- as_messydate(c("2001-01-01", "2001-01-01..2001-01-31", "2001-01-01..2001-12-31", "2001-01-01..2001-02-02", "{2001-10-01,2001-10-04}", "{2001-01-01..2001-01-31,2001-02-02}", "-2000-01-01", "2001-XX-01")) e <- expand(d) test_that("contract works properly", { expect_equal(contract(e), d) expect_equal(contract(e, collapse = FALSE), dd) expect_equal(contract("{2001-01-01, 2001-01-02, 2001-01-03}"), as_messydate("2001-01-01..2001-01-03")) })