year.length {seas} | R Documentation |
Calculate the number of days in a year
Description
Determines the number of days per year using a given calendar.
Usage
year.length(x, calendar)
Arguments
x |
year or a |
calendar |
calendar, see details |
Details
The number of days per year depends on the choice of
calendar. Calendar names used in the function are the same defined
for the CF conventions, used for netCDF files. If a calendar is not
specified (or NULL
), then it is assumed to
be a proleptic Gregorian calendar (which extends before
1582-10-15). Other accepted calendars are:
-
"360"
: always 360-days per year -
"365_day"
or"noleap"
: always 365-days per year -
"366"
or"all_leap"
: always 366-days per year -
"julian"
: 366 days on years divisible by 4, otherwise 365 days
Value
Returns a vector the same length as x
with the numbers of days
corresponding to each year.
Author(s)
Mike Toews
References
http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html#calendar
See Also
Examples
cal <- data.frame(year=c(1899, 1900, 1904, 2000, 2080, 2100))
cal[["Gregorian"]] <- year.length(cal$year)
cal[["Julian"]] <- year.length(cal$year, "julian")
cal[["360_day"]] <- year.length(cal$year, "360_day")
cal[["365_day"]] <- year.length(cal$year, "365_day")
cal[["366_day"]] <- year.length(cal$year, "366_day")
cal