Calculate number of days in a year based on whether it is a leap year or not.

days_in_year(year, leap_year = TRUE)

Arguments

year

Numeric year (can be a vector)

leap_year

Default = TRUE. If set to FALSE will always return 365

Value

integer vector, all either 365 or 366

Examples

# NOT RUN {
days_in_year(2010)  # Not a leap year -- returns 365
days_in_year(2012)  # Leap year -- returns 366
days_in_year(2000:2008)  # Function is vectorized over years
# }