day_of_week
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
day_of_week [2017.11.14 13:28] – created 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. |
+ | [[calendars for demo]] | ||
===Century=== | ===Century=== | ||
Line 13: | Line 16: | ||
===Computing=== | ===Computing=== | ||
- | | + | This is the odd-plus-eleven method. |
+ | | ||
+ | - 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 43: | 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.1510694905.txt.gz · Last modified: 2021.12.22 11:17 (external edit)