History of Modern Calendar Part-1 (Leap Year)

Background:
We, a bunch of friends, were in a tea stall and discussing about several matters. Suddenly a question was raised about why we need to add one additional day after every four years (leap years) which gives us February 29. The first answer was, “We calculate 24 hours a day, but it is not true. Actually one day is 23 hours 56 minutes and 4.1 seconds”. So, actually we are advancing 3 minutes 55 seconds and 900 milliseconds each day from solar year. So, we started calculating the total time for four years expecting that total will be same as one day which we add in leap years. We tried lots of possible ways. But all of the answers were around three days (instead of one). Instead of banging our heads to the wall, we started reading wikis and found some more information that was getting us close to the real answer.

A solar year means the time taken by earth to rotate once which is 365 days 5 hours 48 minutes 46 seconds. But our calendar year consists of only 365 days. So, we are being ahead of 5 hours 48 minutes and 46 seconds each year. As a result, after each four years, we add 6*4=24 hours or 1 day to the calendar (February 29). Note: Instead of 5 hours 48 minutes and 46 seconds, we are being ahead of 6 hours per year. After this adjustment, we are (11 minutes 14 seconds)x4 behind the solar system after each four years. In future, we will have to skip a day when this (11 minutes 14 seconds) per years becomes equal of one day.

The calendar we are using as standard through world is called Gregorian Calendar. It is named after Pope Gregory XIII, who introduced it in October 15, 1582. Before the Gregorian calendar, Julian calendar was being used. So, when we moved to Gregorian Calendar, we drifted From 4th October, 1582 (Julian) to 15th October, 1582 (Gregorian).

Leap Year:
A leap year (also known as an intercalary year or bissextile year) is a calendar year containing one additional day (or, in the case of lunisolar calendars, a month) added to keep the calendar year synchronised with the astronomical/seasonal/solar year.

Simplified version: All the years, in which we add one additional day to sync with Solar system (6×4=24 hours), are called leap year.

Leap year in Julian Calendar:
Each year which is divisible by 4 is a leap year.

Leap year in Gregorian Calendar:
if (year is not divisible by 4) then (it is a common year)
else if (year is not divisible by 100) then (it is a leap year)
else if (year is not divisible by 400) then (it is a common year)
else (it is a leap year)

Note: There are too many leap years in Julian calendar than Gregorian calendar. Fixing this error was the original intention to create a new calendar system (Gregorian) which is more accurate than the Julian calendar.