This S7 generic function extracts the cycle (the cyclical time granule) from a time object, such as cyclical time representations.
Arguments
- x
A time object (e.g., base::Date, base::POSIXct,
linear_time(), etc.)- ...
Additional arguments for methods.
Value
A time duration() object representing the cycle of each value
(e.g. weeks(1L)), or NA if the object has no cyclical component.
Examples
# Non-cyclical objects return NA
time_cycle(Sys.Date())
#> <mixtime[1]>
#> [1] NA
# The cycle of a cyclical time object
time_cycle(month_of_year(Sys.Date()))
#> <mixtime[1]>
#> [1] 1 year