Week 1 - Calculating the Calendar Mentally. Learning the Sequence of Days 1 to 31.This is a short course about an algorithm to calculate the calendar using only simple arithmetic mental calculations.

Currently there's only 1 video for Week 1, but it should give enough time to understand each part of the course in a fine-grained manner.

The algorithm is very lightweight so it is suitable to allow for mental usage and calculations with it, so it should also be extremely simple, optimized and lightweight if used to implement a date managing application, for example in an open source BIOS or in a kernel.

It isn't about calculating a timestamp but the actual day numbers 1-31 and its corresponding weekday names.

**Quote:**

Calculating the Calendar Mentally.

Learning the Sequence of Days 1 to 31.

The first thing we need to learn to mentally calculate the calendar is learning the sequence of the days in vertical order. It will allow us to reach all weeks of the month fast for any day, will also allow us to obtain all the day numbers for every weekday.

The only other thing that we must never forget is the weekday name in which the month starts, and also the number of days in that month. We simply must memorize that, and normally it's enough to memorize it for the current month. Over time it will become more routinary to remember those details.

We have months with 28, 29, 30 and 31 days, but if we learn the sequence for 31 days we can calculate any day of shorter months.

The following is the verbal sequence we need to learn. A single line is the sequence for a single weekday. The month can start at any day, so the sequence for day 1 or the rest of these sequences can fall at any weekday name:

1, 8, 15, 22, 29.

2, 9, 16, 23, 30.

3, 10, 17, 24, 31.

4, 11, 18, 25.

5, 12, 19, 26.

6, 13, 20, 27.

7, 14, 21, 28.

Just memorize the previous numbers and see if you can then inspect the calendar for the current month and match this sequence with the sequence for the actual month that you are interested in. There are only 7 weekdays so this list can only start in 7 different ways, but this same sequence is used for all 7 combinations.

Now see if you can determine the first day of the week without looking at the calendar as well as the last day. Practice with other days as you need them.

Determining the Last Day.

We have months with 28, 29, 30 and 31 days.

28-day months end the weekday before they started.

29-day months end the same weekday in which they started.

30-day months end the next weekday from which they started.

31-day months end two weekdays after the one in which they started.

The first day of the following month is simply the very next weekday for any of the last weekdays we just described.

Now see if you can calculate the last weekday for this month and then the first weekday for the next month by advancing to the following weekday.

Now also try to calculate the weekday of several birthdays or deadline weekdays for when you need to finish or pay something. Also try to calculate the weekdays for the next Saturday and Sunday.