Why calendar dates shift from one year to the next
A common year has 365 days, which is 52 complete weeks plus one extra day. That extra day is why a birthday, the first day of school, or the first of a month usually moves forward by one weekday in the next year. A leap year has two extra days beyond 52 weeks, so dates after February move forward by two weekdays.
The Gregorian leap-year rule keeps the calendar close to the solar year. Years divisible by four receive February 29, except century years that are not divisible by 400. The distinction matters in a calendar generator: 1900 was not a leap year, while 2000 was. Treating every fourth year as a leap year would put every date after February 1900 on the wrong weekday.
Month grids also need a place for days before the first and after the last. This tool always builds six complete week rows. Months that need only five rows simply keep the last row open, which gives you extra writing room and keeps printed calendars consistent from month to month.