Converts numeric offset values to R Date or POSIXct using CF convention
time units and calendar. For standard/gregorian/proleptic_gregorian
calendars (and NULL, the common case), uses base R date arithmetic.
For non-standard calendars (360_day, noleap/365_day, all_leap/366_day),
delegates to the CFtime package if available.
Usage
cf_decode_time(values, units, calendar = NULL)
Arguments
- values
Numeric vector of time values (e.g. days since origin)
- units
CF time units string (e.g. "days since 1800-01-01")
- calendar
CF calendar type. NULL or "standard"/"gregorian"/
"proleptic_gregorian" use base R. Non-standard calendars require CFtime.
Value
Date vector (for whole-day units on standard calendars),
POSIXct (for sub-day units), or character timestamps (non-standard
calendars via CFtime).
Examples
# OISST: days since 1800-01-01 (standard calendar)
cf_decode_time(c(66443, 66474), "days since 1800-1-1 00:00:00")
#> [1] "1981-12-01" "1982-01-01"
# BRAN: days since 1979-01-01
cf_decode_time(c(11323, 11324), "days since 1979-01-01")
#> [1] "2010-01-01" "2010-01-02"