calendar_leap_year() detects if the year is a leap year according to the Gregorian calendar. It is only relevant for calendar types that use a Gregorian year, i.e. year_month_day(), year_month_weekday(), and year_day().

calendar_leap_year(x)

Arguments

x

[calendar]

A calendar type to detect leap years in.

Value

A logical vector the same size as x. Returns TRUE if in a leap year, FALSE if not in a leap year, and NA if x is NA.

Examples

x <- year_month_day(c(2019:2024, NA)) calendar_leap_year(x)
#> [1] FALSE TRUE FALSE FALSE FALSE TRUE NA