day_of_week
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
day_of_week [2017.11.14 15:44] – Steve Isenberg | day_of_week [2022.11.12 13:06] (current) – Steve Isenberg | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOCACHE~~ //<fc # | ||
+ | |||
=====Doomsday algorithm===== | =====Doomsday algorithm===== | ||
Given a date, determine the day of the week it falls on. All based on last day of February in the year, the doomsday. | Given a date, determine the day of the week it falls on. All based on last day of February in the year, the doomsday. | ||
Line 15: | Line 17: | ||
===Computing=== | ===Computing=== | ||
This is the odd-plus-eleven method. | This is the odd-plus-eleven method. | ||
- | - Determine anchor day of Century. | + | - Determine anchor day of Century. |
+ | - Now work with the last 2 digits of year. | ||
- Is year odd? If so add 11 | - Is year odd? If so add 11 | ||
- Divide by 2 | - Divide by 2 | ||
Line 45: | Line 48: | ||
18 is even, /2 is 9, 9 is odd +11 is 20. Mod 7 is 6, from 7 is 1, so doomsday for 1918 is Thursday\\ | 18 is even, /2 is 9, 9 is odd +11 is 20. Mod 7 is 6, from 7 is 1, so doomsday for 1918 is Thursday\\ | ||
Nov 7 is Thursday, so 11th is Monday. | Nov 7 is Thursday, so 11th is Monday. | ||
+ | |||
+ | |||
+ |
day_of_week.1510703094.txt.gz · Last modified: 2021.12.22 11:17 (external edit)