Use of cal with a month number and a year number to get a weekday of a
particular date can make work a little easier.
This is for really long time periods and only inside the gregorian
calendar constraints since outside of those constraints things get really
wild as a result of compound errors.
With that weekday in mind subtracting a year when you won't land in a leap
year or adding a year when you won't land in a leap year, subtract or add
one weekday to get the correct weekday for that date in those years. If
you will land in a leap year, subtract or add two weekdays to get the
correct weekday. Modulus the weekday by 7 to keep it in whichever range
you prefer to use..
That can get you to the correct forest, then it's a matter of smaller
subtraction or addition within a year to get you your exact length.