leap_year: Is a year a leap year?

Description Usage Arguments Value Examples

View source: R/leap-years.r

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, leap_year returns whether it would be a leap year under the Gregorian calendar.

Usage

1

Arguments

date

a date-time object or a year

Value

TRUE if x is a leap year, FALSE otherwise

Examples

1
2
3
4
5
6
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

Example output

Attaching package: 'lubridate'

The following object is masked from 'package:base':

    date

[1] FALSE
[1] FALSE
[1] TRUE
[1] FALSE
[1] TRUE

lubridate documentation built on Feb. 26, 2021, 5:09 p.m.