This class represents a standard CF calendar, but with the Gregorian calendar extended backwards to before the introduction of the Gregorian calendar. This calendar is compatible with the standard POSIXt calendar, but note that daylight savings time is not considered.
This calendar includes dates 1582-10-14 to 1582-10-05 (the gap between the Gregorian and Julian calendars, which is observed by the standard calendar), and extends to years before the year 1, including year 0.
CFtime::CFCalendar
-> CFCalendarProleptic
new()
Create a new CF calendar.
CFCalendarProleptic$new(nm, definition)
nm
The name of the calendar. This must be "proleptic_gregorian". This argument is superfluous but maintained to be consistent with the initialization methods of the parent and sibling classes.
definition
The string that defines the units and the origin, as per the CF Metadata Conventions.
A new instance of this class.
valid_days()
Indicate which of the supplied dates are valid.
CFCalendarProleptic$valid_days(ymd)
ymd
data.frame
with dates parsed into their parts in columns
year
, month
and day
. Any other columns are disregarded.
Logical vector with the same length as argument ymd
has rows
with TRUE
for valid days and FALSE
for invalid days, or NA
where
the row in argument ymd
has NA
values.
month_days()
Determine the number of days in the month of the calendar.
CFCalendarProleptic$month_days(ymd = NULL)
ymd
data.frame
, optional, with dates parsed into their parts.
Integer vector indicating the number of days in each month for
the dates supplied as argument ymd
. If no dates are supplied, the
number of days per month for the calendar as a vector of length 12, for
a regular year without a leap day.
leap_year()
Indicate which years are leap years.
CFCalendarProleptic$leap_year(yr)
yr
Integer vector of years to test.
Logical vector with the same length as argument yr
. NA
is
returned where elements in argument yr
are NA
.
POSIX_compatible()
Indicate if the time series described using this calendar
can be safely converted to a standard date-time type (POSIXct
,
POSIXlt
, Date
).
CFCalendarProleptic$POSIX_compatible(offsets)
offsets
The offsets from the CFtime instance.
TRUE
.
date2offset()
Calculate difference in days between a data.frame
of time
parts and the origin.
CFCalendarProleptic$date2offset(x)
x
data.frame
. Dates to calculate the difference for.
Integer vector of a length equal to the number of rows in
argument x
indicating the number of days between x
and the origin
,
or NA
for rows in x
with NA
values.
offset2date()
Calculate date parts from day differences from the origin. This only deals with days as these are impacted by the calendar. Hour-minute-second timestamp parts are handled in CFCalendar.
CFCalendarProleptic$offset2date(x)
x
Integer vector of days to add to the origin.
A data.frame
with columns 'year', 'month' and 'day' and as many
rows as the length of vector x
.
clone()
The objects of this class are cloneable with this method.
CFCalendarProleptic$clone(deep = FALSE)
deep
Whether to make a deep clone.