The reason for adding leap days to the calendar is to align the calendar year with the actual year – which is defined by the time it takes Earth to circle the sun. It is equal to 365 days, 5 hours, 48 minutes and 46 seconds, or 365.24219 days.
. leap year or not?
A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400. If a year is divisible by 4, 100 and 400, it's a leap year. If a year is divisible by 4 and 100 but not divisible by 400, it's not a leap year. If a year is divisible by 4 but not divisible by 100, it's a leap year. If a year is not divisible by 1, it's not a leap year. This logic can be implemented in any programming language.