Learn R Programming

CFtime (version 1.6.0)

CFCalendar365: 365-day CF calendar

Description

This class represents a CF calendar of 365 days per year, having no leap days in any year. This calendar is not compatible with the standard POSIXt calendar.

This calendar supports dates before year 1 and includes the year 0.

Arguments

Super class

CFtime::CFCalendar -> CFCalendar365

Methods

Inherited methods


Method new()

Create a new CF calendar of 365 days per year.

Usage

CFCalendar365$new(nm, definition)

Arguments

nm

The name of the calendar. This must be "365_day" or "noleap".

definition

The string that defines the units and the origin, as per the CF Metadata Conventions.

Returns

A new instance of this class.


Method valid_days()

Indicate which of the supplied dates are valid.

Usage

CFCalendar365$valid_days(ymd)

Arguments

ymd

data.frame with dates parsed into their parts in columns year, month and day. Any other columns are disregarded.

Returns

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.


Method month_days()

Determine the number of days in the month of the calendar.

Usage

CFCalendar365$month_days(ymd = NULL)

Arguments

ymd

data.frame, optional, with dates parsed into their parts.

Returns

A 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.


Method leap_year()

Indicate which years are leap years.

Usage

CFCalendar365$leap_year(yr)

Arguments

yr

Integer vector of years to test.

Returns

Logical vector with the same length as argument yr. Since this calendar does not use leap days, all values will be FALSE, or NA where argument yr is NA.


Method date2offset()

Calculate difference in days between a data.frame of time parts and the origin.

Usage

CFCalendar365$date2offset(x)

Arguments

x

data.frame. Dates to calculate the difference for.

Returns

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.


Method 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.

Usage

CFCalendar365$offset2date(x)

Arguments

x

Integer vector of days to add to the origin.

Returns

A data.frame with columns 'year', 'month' and 'day' and as many rows as the length of vector x.


Method clone()

The objects of this class are cloneable with this method.

Usage

CFCalendar365$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.