2005

DEADBEAT PAYING JOB • chapter 105

 

pst

mon
feb
21

Laziness had taken us down a slightly errant path. Rather than adding 5, 10, 15, 20, 25, 30, 35, 40, ..., we're subtracting 2, 4, 6, 8, 10, 12, 14, 16, ..., for the years 1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, ....

Every time we use this second method for the years between the years already mentioned, we're always wrong by 6, 4 and 3. That is, for 1900, the error is 0; the calculation is right on the mark. For 1901, the calculation is off by 6; for 1902, the calculation is off by 4; for 1903, the calculation is off by 3.

Then for 1904, the calculation is totally correct. Thus we have a repeated error of 0, 6, 4, 3, 0, 6, 4, 3, 0, 6, 4, 3, ..., for the years 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, ....

Notice that an error of 6 is the same thing as an error of -1; an error of 4 is the same thing as an error of -3; and an error of 3 is the same thing as an error of -4. So we can repeat this same error pattern as follows: 0, -1, -3, -4, 0, -1, -3, -4, 0, -1, -3, -4, ..., for the years 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, ....

So here's the final year adjustment: Take the last two digits of the year; divide by 2, dropping any remainder; if that result is odd, subtract 3; if the original year is odd, subtract 1. Count UP to the nearest multiple of 7, and that's it.

That sequence will correct any errors, don't ask me why. It just does.

pm
8:38

 

 

 

Of course, we still have to account for differences between centuries.

From 1900 to 1999, including the leap day snatched backwards from 2000, we have (365+365+365+366 days) x (25 4-year sequences in a century) = 36525 days in the 20th century.

36526 is evenly divisible by 7, so we're one short of the mark.

From 2000 to 2099, including no leap day snatched backwards from 2100, because that centesimal year is a common year, we have (365+365+365+366 days) x (25 4-year sequences in a century) - 1 = 36524 days in the 21st century, which is two short of the mark.

Factoring this information into the year adjustment, we have: Take the last two digits of the year; divide by 2, dropping any remainder; if that result is odd, subtract 3; if the original year is odd, subtract 1. If in the 1900's do nothing; otherwise, if beyond 2000, or 2400, add 1 for each of them; add or subtract 2 for other centuries; Count UP to the nearest multiple of 7, and that's it.

8:59

 

 

 

This whole time we've been sneakily using March 25th as New Year's Day, in order to get any leap day, February 29, hanging off the back of the previous year, rather than throwing off the grid in any actual leap year.

In order to get New Year's Day back where it belongs, at January 1st, we'll use two different month codes for January and February.

If we're in a common year, the month codes for January and February are "x" = 1, and "xfeb" = 4. If we're in an actual leap year, such as 1904, 1908, ..., 1996, 2000, 2004, ..., the month codes for January and February are «none» = 0, and "feb" = 3.

This is equivalent to the Floor Manager locking up the store at the end of the day, then going back in to lock up the cash box, then going back in to turn on the night display lights.

8:59

 
 
 

Day of Week Algorithm

Copyright © 1995-2005 Richard Ames Hart

 

Here's how to calculate the day of the week in your head for any date after September 14, 1752. It's relatively simple once you memorize ten month codes (None needed for April and July).

The aim of this algorithm is to produce a single digit in the range 0 to 6. If it's a 0, it's Saturday; otherwise, 1 through 6 stand for Sunday through Friday. The algorithm takes place in seven steps:


month
mnemonic

month
code

(in
leap
year)

X

1

0

XFeb

4

3

M[arch]

4

--

none

M[ay]

2

Junio

5

--

none

Aug

3

Sep[tember]

6

O

1

Nove

4

De[cember]

6

 
 

(1) Divide the last two digits of the year by 2, dropping any remainder.

(2) If this result is odd, subtract 3.

(3) If the original year is odd, subtract 1.

(4) This algorithm is normalized for the 1900's. Add 1 if in or beyond 2000 or 2400 AD; add or subtract 2 for other centuries (no earlier than 9-14-1752).

(5) If the result is an even multiple of 7, set it to 0; otherwise, set it to whatever amount is needed to reach the next highest multiple of 7. This final figure is the year-offset, in the range 0 to 6.

(6) Add the year-offset, the month code, and the day of month.

(7) Divide by 7 and keep only the remainder. That's the day of the week. Don't forget, in leap years — (those years divisible by 4 and not divisible by 100 unless divisible by 400) — in leap years, the codes for January and February are 0 and 3; otherwise they are 1 and 4. Here are three examples:

 
 
 
 

Junio

30, 1947

Feb

24, 1952, a leap year

July

1, 2032

(1) 47 / 2 = 23

(1) 52 / 2 = 26

(1) 32 / 2 = 16

(2) 23 - 3 = 20

 

 

(3) 20 - 1 = 19

 

 

 

 

(4) 16 + 1 = 17

(5) 19 up to 21 = 2

(5) 26 up to 28 = 2

(5) 17 up to 21 = 4

(6) 2 +

5

+ 30 = 37

(6) 2 +

3

+ 24 = 29

(6) 4 +

0

+ 1 = 5

(7) 37 down to 35 = 2

(7) 29 down to 28 = 1

(7) 5 down to 0 = 5

 

 

 

2 = Monday

1 = Sunday

5 = Thursday

 
 

 

Good days for a picnic.

 

 
 

home < < earlier

 < • > 

> > > chapter 106