1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Testing For Leap Year

Discussion in 'T&T - Scripting' started by Joe Caverly, Aug 23, 2017.

  1. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    The next total eclipse where I presently live is on April 8, 2024

    God willing, I will still be alive to see the eclipse.

    I was wondering if 2024 is a leap year.

    Here's a quick way to determine if a year is a leap year;

    Code:
    echo %@doy[2024-12-31,4]
    ...which reutrns

    Code:
    366
    ...which means that 2024 is a leap year.

    Joe
     
    TEA-Time likes this.
  2. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    Not quite. That's what Y2k was about. Centuries are only leap years if they are evenly divisible by 400, i.e., 1700, 1800 and 1900 were not leap years but 2000 was, but 2100 won't be.

    Doesn't seem like a big deal but the Y2k problem was originally noticed in 1970 when calculations on 30-year mortgages were being done.

    (Mortgages almost never are more than 30 years because beyond that the monthly payment is almost the same regardless of length, i.e. the difference between a 30 year vs. 40 year mortgage at the same interest rate might be $50 a month.)
     
  3. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    Code:
    echo %@doy[2000-12-31,4]
    returns
    Code:
    366
    Code:
    echo %@doy[2100-12-31,4]
    returns
    Code:
    365
    A leap year has 366 days.

    A non-leap year has 365 days.

    Joe
     
    TEA-Time likes this.

Share This Page