Main Content

leapyear

Determine leap year

    Description

    ly = leapyear(year) determines whether one or more years are leap years.

    example

    Examples

    collapse all

    This example shows how to determine if 2005 is a leap year.

    ly = leapyear(2005)
    ly = logical
       0
    
    

    This example shows how to determine whether 2000, 2005, and 2020 are leap years.

    ly = leapyear([2000 2005 2020])
    ly = 1x3 logical array
    
       1   0   1
    
    

    Input Arguments

    collapse all

    Year to be evaluated, specified as an array or scalar. The function floors non-integer values to the nearest integer value.

    Data Types: double

    Output Arguments

    collapse all

    Leap year determination, returned as a scalar or array as a logical value.

    Limitations

    The determination of leap years is done by Gregorian calendar rules.

    Version History

    Introduced in R2006b