I use a table to validate the length of the months and also check for leap year. IsLeapYear first tests if the year is divisible by 100 and 400. If so it is a leap year, otherwise not. The final check is if the year is divisible by 4. The destination string szDest is input to the routine and must be at least 11 bytes in length.
Return value is a pointer to the formatted destination string.
This function determines the number of total days as determined by the instance variables month and day. I use a days table indexed by the month to retrieve the total days accumulated by the month to which I add the instance variable day. If a leap year I adjust the table to account for the extra day. This function implements the formula developed earlier to transform a calendar date into the reference system. The formula works well except when the year is at the end of one of those 400 year intervals when it calculates one extra day.