granularities()
will return a character vector of canonical granularity names for the
relevant calendar. These are the granularities used to define dates on the calendar.
granularity()
will return a vector of numerical values for a given canonical granularity.
Value
A character vector of granularity names or a vector of numerical values for the specified granularity.
See also
week_of_year for some non-canonical granularities.
Examples
granularity_names(cal_iso)
#> [1] "year" "week" "day"
granularity_names(cal_gregorian)
#> [1] "year" "month" "day"
date_iso <- new_date(year = 2025, week = 23, day = 2, calendar = cal_iso)
granularity(date_iso, "week")
#> [1] 23
date_gregorian <- new_date(year = 2025, month = 1, day = 1, calendar = cal_gregorian)
granularity(date_gregorian, "month")
#> [1] 1