A leap year adds one day, 29 February, to keep the calendar in step with the seasons. The U.S. Naval Observatory states the rule: years evenly divisible by 4 are leap years, except centurial years that are not evenly divisible by 400. So 2000 and 2028 are leap years, while 1900 and 2100 are not.
Formula
leap if (y mod 4 = 0 and y mod 100 ≠ 0) or (y mod 400 = 0)
y is the year number and mod is the remainder after division.
Example
A leap year has 366 days = 52 weeks and 2 days (how many weeks in a year). In seconds that is 366 × 86,400 = 31,622,400, against 31,536,000 for a 365-day year (how many seconds in a day). Over 400 years the rule gives 97 leap years, so the average year is (303 × 365 + 97 × 366) ÷ 400 = 365.2425 days, as in the Gregorian calendar.
Common mistakes
Treating every year divisible by 100 as a leap year is wrong: 2100 is not one. The date duration calculator counts leap days automatically.