Learn R Programming

lubridate (version 1.9.5)

leap_year: Is a year a leap year?

Description

If x is a recognized date-time object, leap_year will return whether x occurs during a leap year. If x is a number, it is interpreted as a year in the Gregorian calendar and leap_year returns TRUE if it is a leap year.

Usage

leap_year(date)

Value

TRUE if x is a leap year, FALSE otherwise

Arguments

date

a date-time object or a year

Examples

Run this code
x <- as.Date("2009-08-02")
leap_year(x) # FALSE
leap_year(2009) # FALSE
leap_year(2008) # TRUE
leap_year(1900) # FALSE
leap_year(2000) # TRUE

Run the code above in your browser using DataLab