seas (version 0.4-3)

year.length: 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 Date

calendar

calendar, see details

Value

Returns a vector the same length as x with the numbers of days corresponding to each year.

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

References

http://www.cgd.ucar.edu/cmw/eaton/cf-metadata/CF-current.html#cal

See Also

mkseas, mkann

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab