# date coercion
as_epiweek(Sys.Date())
# POSIXt coercion
as_epiweek(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"))
# character coercion assumes date input by default
as_epiweek("2019-05-03")
# character coercion can handle YYYY-Www format too
as_epiweek("2019-W12", format = "yearweek")
# construction
epiweek(year = 2000, week = 3)
# direct construction
stopifnot(
identical(
new_epiweek(0:1),
as_epiweek("1970-01-04") + 0:1
)
)
Run the code above in your browser using DataLab