# date coercion
as_yearquarter(Sys.Date())
# POSIXt coercion
as_yearquarter(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"))
# character coercion
as_yearquarter("2019-05-03")
# construction
yearquarter(year = 2000, quarter = 3)
# direct construction
d <- seq.Date(from = as.Date("1970-01-01"), by = "quarter", length.out = 4)
stopifnot(
identical(
as_yearquarter(d),
new_yearquarter(0:3)
)
)
Run the code above in your browser using DataLab