6 ms·
Doomsday rule: calculate the day for any date
- gamegoblin 12y agoFreshman year of uni I memorized some variant of this, and after some practice I got to where I could do the math in 3-5 seconds. Protip: Some parts of the algorithm can be subject to a CPU/Memory trade off. In the variant presented in the wiki article, steps 1 and 2 can be combined. Memorize the doomsdays for all of the years of people you're likely to want to calculate their date of birth. For me, this meant memorizing the doomsdays between say, 1980 and 1995. You can also memorize a modulo 7 table for all numbers you're likely to encounter. You can get fast enough in the amount of time it takes you to say some canned response "Hmm, I think the date X YYth of ZZZZ would fall on..." you can figure out the answer. ----- Though it turns out this is a significantly less impressive party trick as I initially imagined it'd be.
- iamwil 12y agoPeople aren't impressed by it?
- gamegoblin 12y agoOnly a certain kind of people really appreciate it. Generally, the same kind of people who are impressed by rubik's cube speedsolving (which I also thought would be amazingly cool) are impressed by this. But for a lot of people, they just assume there is some simple trick to it, say "cool" and move on. And then other people assume you must be some sort of autistic savant.
- dools 12y agoI found the same for the ability to divide numbers by 17 in my head... it really didn't get me a lot of action.
- eps 12y agoIt's hard to know if the answer you are given is in fact correct unless you knew it beforehand.
- gamegoblin 12y agoFortunately, I've found that most people know which day of the week they were born on. Once or twice, though, someone was mistaken and upon consulting wolfram alpha, we determined the doomsday algorithm was correct.
- allegory 12y agoMost people are impressed by what a person owns or looks like, not what they are capable of or what value they can add to the world. It saddens me. I'd sit with someone who did this and learn how it works! My party trick clears the room: eye socket farts.
- Borg33414625035 12y agoHere's my formula for D/M/Y where Y=YYYY=CCFS (CC=century digits F=First S=Second digit of the last two digits in year) Note:Only for Gregorian calendar. Formula= {D +Table(M) -1 IF month=1or2&leap_year +Table(CCmod4) +Table(F) +Table(S +2 IF F is odd) } mod7 Tables are: Month {033614625035} or Jan=0 Feb=3 Mar=3 Apr=6 etc. Century {6420} or 16xx=6 17xx=4 18xx=2 19xx=0 20xx=6 etc. TableFirst memorize {0340145025} or {00,13,24,30,41,54,65,71,82,95} TableSecond memorize {012356013456} or {00,11,22,33,45,56,60,71,83,94,105,116} FormulaResultTable:1=Monday...6=Saturday 0=Sunday Example: 16 August 2014 = (16+2+6+3+0)mod7=6=Saturday In this method,I find slight advantage over "odd+11 method" because my method does not involve two digit arithmetric (and memorizing running total if you're not calculating FS first),although learning tables take some time.
- adamnemecek 12y agoThe 'Big Calendar' industry is going down.
- madcaptenor 12y agoBig Calendar is already on its way down. How many of us even have calendars?
- deleted 12y ago[deleted]
- daurnimator 12y agoWhen I wrote my time and date library (luatz: https://github.com/daurnimator/luatz https://github.com/daurnimator/luatz ) I originally wrote an implementation of the Doomsday rule to figure out the day of the week. Turns out that sakamoto's algorithm (see https://en.wikipedia.org/wiki/Calculating_the_day_of_the_week#Implementation-dependent_methods_of_Sakamoto.2C_Lachman.2C_Keith_and_Craver https://en.wikipedia.org/wiki/Calculating_the_day_of_the_wee... ) was much faster to calculate and made for cleaner code. https://github.com/daurnimator/luatz/blob/master/luatz/timetable.lua#L45 https://github.com/daurnimator/luatz/blob/master/luatz/timet...
- apaprocki 12y agoIIRC tzdata just acquired a new version (3) not too long ago and luatz would need to be updated to handle it. You'll only get the new files if they were compiled with a newish zic. This bit me because code I work with is also parsing them :)
- daurnimator 12y agoThanks for mentioning this, I had no idea... and documentation on this fact is sparse. It's not even mentioned on https://www.iana.org/time-zones/repository/tz-link.html https://www.iana.org/time-zones/repository/tz-link.html Created an issue at https://github.com/daurnimator/luatz/issues/2 https://github.com/daurnimator/luatz/issues/2
- rspeer 12y agoRight, the Doomsday Rule is optimized for humans, not computers.
- vorg 12y agoIt seems the algorithm would be better optimized for humans if January and February were always considered to be the last two months of the previous year. We're already used to doing this when working out birth years for Horoscopes and the Chinese calendar. Then we wouldn't need to memorize different dates for Doomsday in Jan and Feb, and instead remember Jan 2, Feb 6, etc.
- oh_sigh 12y agoThis rule is great for convincing people that you are autistic.
- cstuder 12y agoWhy are those days called 'doomsdays'? Anybody knows? (The origin articles don't seem to be online.)
- scotty79 12y agoMaybe because its inventor is John Conway? You know, "Conway's Game of Life", "Doomsday rule"... He's not into small names for the things he invented.
- lordbusiness 12y agoI do believe the etymology in this case lies with Old English 'domes dæg' which was thought to be some apocalypse 6,000 years after creation, which was thought to be ca. 5,200BCE. As for your question why, I cannot reasonably guess. :-) Somewhat related, you may be interested to read up about the Doomsday Book.
- hashmymustache 12y agoNot sure how the doomsday works, but there's a quick way to calculate the day of week just memorizing single digit codes for months. Might be easier to grok from a small script. This is for current century (2000s) in coffeescript: calculateDay = (year,month,day) -> y = (year-2000)%28 m = [6,2,2,5,0,3,5,1,4,6,2,4][month] if month < 2 and y%4==0 m-= 1 y += y/4|0 days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] return days[(y+m+day)%7] --- For years 1600s through current century here's a jsfiddle with a slightly longer method with verification: http://jsfiddle.net/9zp0zkxz/ http://jsfiddle.net/9zp0zkxz/ Edit: no idea how to work spacing on comments here
- ColinWright 12y ago> no idea how to work spacing on comments here * Blank lines create new paragraphs, Blank line followed by lines with leading spaces create pre-formatted text - intended for inserting code. Under most circumstances, asterisks around text creates italics, the exception is when the asterisk is surrounded by space. -- https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- hashmymustache 12y agoah, thank you
- elwell 12y agocalculateDay = (year, month, day) -> y = (year - 2000) % 28 m = [6,2,2,5,0,3,5,1,4,6,2,4][month] m-- if month < 2 and y % 4 is 0 y += (y / 4) | 0 ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][(y + m + day) % 7]
- jeffboudier 12y agoThe periodic calendar provides a map to this math: http://periodiccalendar.com/learn/ http://periodiccalendar.com/learn/
- apeconmyth 12y agoThanks, Jeff! The key to the Periodic Calendar is identifying that there are seven types of years, depending on the day of the week that starts it off. At first I thought I needed to make 7 calendars to cover the possibilities, but my aha moment came with the idea of the Gregorian Isotopes, which flip our focus from the day of the month to elements based in days of the week that exist on an array of days of the month. The core idea is that August 10th is a semi-meaningless count of the days, whereas the real information lies in today being Sunday.
- jeffboudier 12y agoThe periodic calendar provides a map to this math: http://periodiccalendar.com/learn/ http://periodiccalendar.com/learn/
- troymc 12y ago"Pick a date, any date." "June 12, 2145." "A Saturday. In Vancouver, sunrise will be at 5:12am and sunset will be at 9:24pm. There will be a third quarter moon." "Wow." http://www.wolframalpha.com/input/?i=June+12%2C+2145 http://www.wolframalpha.com/input/?i=June+12%2C+2145
- rdvrk 12y agohttp://www.wolframalpha.com/input/?i=January+2%2C+218129 http://www.wolframalpha.com/input/?i=January+2%2C+218129 sunrise: not reached :|
- apeconmyth 12y agoAs I explained to a friend recently, I'm not the type of person who can readily do the calc in my head, but rather the type who would enjoy the tedious work of laying out all the possibilities on paper, as I did with the Periodic Calendar: http://periodiccalendar.com/ http://periodiccalendar.com/
- jozydapozy 12y agoThis script will test your skills on logon: https://code.google.com/p/doomsday-sh/ https://code.google.com/p/doomsday-sh/
- bumbledraven 12y agoThe First Sunday Doomsday Algorithm is the easiest to learn and also fastest, in my opinion. http://firstsundaydoomsday.blogspot.com/ http://firstsundaydoomsday.blogspot.com/