Generally there are 365 days in a calendar year. However the length of an astronomical year is about 365.242375 days, so in the course of time the fractional part would result in an extra day and the calendar year would lag from the astronomical. To avoid this the an extra day was invented to create the 366 day leap year.
The Gregorian calendar is the current standard calendar in most of the world and it adds a 29th day to February in all years evenly divisible by 4, except for centennial years, those ending in '00, which only receive the extra day if they are evenly divisible by 400.
Utilities object has a special method,
IsLeapYear, that accepts the year number and returns true if the specified year is a leap year. We can use this method to get the exact number of days in the desired year:
IsLeapYear method we can get the number of days in the month. For all months, except February, the duration of a month is fixed and is either 30 or 31 days. The duration of February is 28 or 29 days depending on whether the current year is a leap year or not. The routine that gets the month duration would be the following: