Main Content

leapyear

Determine leap year

    Description

    example

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

    Examples

    collapse all

    Determine whether 2005 is a leap year.

    ly = leapyear(2005)
    ly =
      logical
    
       0

    Determine if 2000, 2005, and 2020 are leap years.

    ly = leapyear([2000 2005 2020])
    ly =
      1×3 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.

    Introduced in R2006b