How do the days of a date in the Gregorian calendar change through the years?

Each year, the day a date can have goes forward one day, however, on a leap year it goes forward two days; due to the leap years, the days a date can have follows a 28 day cycle:

{Mo, Tu, We, Th}, {Sa, Su, Mo, Tu}, {Th, Fr, Sa, Su}, {Tu, We, Th, Fr}, {Su, Mo, Tu, We}, {Fr, Sa, Su, Mo}, {We, Th, Fr, Sa}

where each block of 4 represent sequential days before a missed day when the leap year occurs. Note that each day appears exactly 4 times, once in each position (each time in a different block) so that each day starts one of the blocks. If the date is after 28 February, the jump occurs in a leap year, but for those before 1 March, the jump occurs in the year after a leap year.

A century is one hundred years long, which means that each year will take 25 blocks from the above cycle to complete: 3 complete cycles plus the first 4 blocks. Numbering the blocks from 0 to 6 in the sequence above:

block 0: {Mo, Tu, We, Th};

block 1: {Sa, Su, Mo, Tu}; ...

block 6: {We, Th, Fr, Sa}

and assuming a date was a Monday in the first year of a leap century, then the blocks used in that century would be:

0123456 0123456 0123456 0123

(If the first day was another day, then the sequence would start from the block which starts with that day, eg if it was a Tuesday, then the block sequence would be: 3456012 3456012 3456012 3456.)

In the Gregorian Calendar a century is only a leap year if the century is divisible by 400. Thus 2000 was a leap year, but 1900 was not. Thus the above cycle of 28 days jumps for 3 out of 4 centuries when the day of the date at the start of the next century follows the day of the last year of the current century.

So carrying on from the above, as the century was a leap year, the next block must start with the day following the last day of the last block, ie the day after the last day of block 3 which is Friday, the block starting with Saturday - block 1; thus the next century would have the block sequence:

1234560 1234560 1234560 1234

Which is one block along from the previous century. So the complete sequence for 4 years starting from a leap century would be:

0123456 0123456 0123456 0123

1234560 1234560 1234560 1234

2345601 2345601 2345601 2345

3456012 3456012 3456012 3456

As the next century would start with a leap year, it starts with the next block in the cyclic sequence, which is block 0 again - the same sequence occurs for every block of 4 centuries starting with a leap century!

From this a complete list of days for every year of any date can be worked out, by changing the start block for the 4 century cycle above.

One this to note is that as the leap day is inserted after 28 February, the years for which the above cycles are appropriate will be slightly different:

For dates after the leap day (ie 1 March and later), the days jump in the leap year itself, so the sequence is appropriate for years starting with the leap century itself, ie the first block relates to the years xx00-xx03, the second to xx04-xx07, etc.

For dates before the leap day (ie 28 February and earlier) the jump occurs the year after the leap year, so the sequence is appropriate for years starting with the year after the leap century, ie the first block relates to the years xx01-xx04, the second to xx05-xx08, etc.

For the leap day itself, that follows the sequence of missing days:

{Tu, Su, Fr, We, Mo, Sa, Th}

Again with jumps on non-leap centuries:

0123456 0123456 0123456 0123

2345601 2345601 2345601 234

3456012 3456012 3456012 345

4560123 4560123 4560123 456

(0 =Tu, 1 = Su, etc).