A leap year is a year that contains one additional day, which in the Gregorian calendar, which is one of the most commonly used calendar in the world, adds one extra day in the month of February after every three years. This means that in a leap year the month of February has 29 days instead of 28 it usually has. The reason behind adding an additional day to the month of February in the Gregorian calendar is to keep the calendar year synchronized with the astronomical or seasonal year.
The reason for adding an extra day to the calendar day is the fact that our Earth doesn’t take exactly 365 days to orbit around the sun. The exact time is closer to 365.242 days, which is often regarded as 365.25 days. To keep the calendar year in sync with the astronomical year, an additional day has to be added every fourth year.
While a lack of six hours a year doesn’t sound like much, this deficit adds up in the long run and since calendars are used for hundreds of thousands of years, this small deficit can create a problem after centuries of use and without the addition, out calendar would eventually fall out of sync with the weather. In the Gregorian calendar, most years that are integer multiples of four are leap years to compensate for that fact that the period of 365 days is shorter than a solar year by six hours. Since its use in 1582, the additional deficit of counting 365.242 as 365.25 also adds up to about three extra days over a period of four centuries. To compensate for this tiny loss, the Gregorian calendar omits three leap days every 400 years, by omitting February 29 in the three century years. Because of this, while the year 2000 was a leap year, the years 2100, 2200 and 2300 won’t be. The Pseudocode for determining whether a year will be a leap year or not in the Gregorian calendar since 1582 is: