Talk:Determination of the day of the week
| WikiProject Time | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Contents |
[edit] Errors
Khennacy changed Alaska's previous owner from Russia to Canada as part of other changes. The sentence is awkward (Russia switched when Alaska was bought by the US from Russia) so I left it alone.
Comment: Whoever entered this statement is falsely reporting the change.
[edit] Algorithms
I don't agree with the pages claims concerning all algorithms. They could always be an algorithm that is a counterexample.
I don't this the paragraph heading The Algorithm. There are other algorithms.
I'd like the page to be about various algorithms and perhaps have a sepate page for each algorithm that is described in detail.
Other algorithms include the Doomsday algorithm which take avantage of the fact that 4 April, 6 June, 8 August, 10 October and 12 December are all the same day of week in a given year.
Also the article may be in violation of copyright. See [[1]], but actually appears to be quite different.
User:Karl Palmen 29 April 2004
- Hi, Karl, I'm the one who mentioned the copyright issue. This actually applied to just a section that was added by a user sometimes known as Hosamsherif who just copied that text from that page. It appears he has now readded that section, but rephrased it enough not to be a copyvio.
- If we add another algorithm, this page could get quite large. Maybe it should just discuss the general idea, and link to a few different algorithms? Kevin Saff 14:50, 29 Apr 2004 (UTC)
Kevin Saff said that if we add another algorithm, this page could get quite large. That is why I suggested putting detailed algorithms on separate pages. The page itself could talk about various ways in which the day of the week is or has been worked out without having to show all the details there.
To be comprehensive and encyclopeadic, it should mention all reasonably well known algorithms.
User:Karl Palmen 30 April 2004
[edit] Lazy alternatives using Wikipedia itself
Now that some brilliant programmers at Wikipedia have done lots of legwork - er - fingerwork, most dates that most people could really want to check up on can be checked with a 4-digit search for the year then (if the calendar isn't displayed) a click on the link that goes to the calendar.
And now we have the marvellous new system of showing month calendars whenever we want to with a deceptively simple set of templates. I'm translating them into Maori, starting with mi:2005. Gets easier as you go on, for at least two reasons, one being that you find shortcuts if your lateral thinking is up to scratch. Talk to me if you want to do it for your language and can't find a guide anywhere. But if anyone has seen such a guide, please point me to it! Where's the best place to create such a guide if we don't have one? Robin Patterson 01:30, 6 Jun 2005 (UTC)
[edit] Centuries error?
The method of calculation in the "Centuries" heading is wrong. You can't obtain correct values using that method. —Preceding unsigned comment added by 129.97.233.144 (talk • contribs)
- It is correct: In the article you stated that you could not obtain 6 from 20xx using the Centuries method. 20/4 yields a quotient of 5 and a remainder of 0. 3−0=3, 3×2=6. QED. You have probably confused the quotient with the remainder. — Joe Kress 04:39, 5 October 2006 (UTC)
-
- The wording was confusing - I made the same mistake. I've reworded it. --... and m@ (talk) 01:14, 31 January 2008 (UTC)
-
-
- I've rewritten the section explaining the algorithm. The part calculating the months was inconsistent with the examples below it, so I deleted that explanation. For the year and month, I've put mathematical equations in, because they are easier to read than an English sentence. I've removed examples in the instructions, the examples which already are included below are sufficient. I personally would refactor this section so that the explanation of the algorithm is separate from the definition, but I think I've modified the article enough for now. --... and m@ (talk) 02:11, 31 January 2008 (UTC)
-
The formula does give the results shown at the centuries table, but those values are wrong because:
1st of January of 1700 starts on friday (5), not thursday (4)
1st of January of 1800 starts on wednesday (3), not tuesday (2)
1st of January of 1900 starts on monday (1), not sunday (0)
Only the 1st of January of 2000 is correct, as it starts on saturday (6). —Preceding unsigned comment added by 189.180.105.160 (talk) 00:08, 30 June 2009 (UTC)
[edit] Another one
I got this one out of a maths book: ![x = (date + (year - [\frac{14 - month}{12}]) + [\frac{31 \times (month + 12[\frac{14 - month}{12}]}{12}] + [\frac{year - \frac {14 - month}{12}]}{4}] -](http://upload.wikimedia.org/wikipedia/en/math/5/a/6/5a6526319b23610e961322580a5237c9.png)
![[\frac{year - \frac {14 - month}{12}]}{100}] + [\frac{year - \frac {14 - month}{12}]}{400}])\operatorname{mod} 7](http://upload.wikimedia.org/wikipedia/en/math/d/5/a/d5a1a2c449daf0c1fe16538296385a93.png)
Then convert x to day:
| x= | day |
|---|---|
| 0 | Sunday |
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
Obviously the formula is a bit big and scary, but you can get rid of a lot of it by doing the algorithm in five steps.
![f = [\frac{14 - month}{12}]](//upload.wikimedia.org/wikipedia/en/math/7/b/9/7b964191e1b95b500c3bc337af2558df.png)
- y = year − f
- m = month + 12f − 2
- Then put into new formula:
![(date + y + [\frac{31m}{12}] + [\frac{y}{4}]-[\frac{y}{100}]+[\frac{y}{400}])\operatorname{mod}7](//upload.wikimedia.org/wikipedia/en/math/5/0/3/5034656949cb42026c22041d2a35856b.png)
- Convert (see table)
Jake95(talk!) 16:00, 20 January 2007 (UTC)
Here's an algorithm I came up with:
- Take a year, divide it by 400, and take the remainder, since 400 years is a whole number of weeks. Subtract 1 from this remainder to get a value called the reduced year.
- Divide the reduced year by 100 and truncate to an integer. The result is called the century number, and is the number of non-leap century years between the first year in the 400-year period—with a reduced year of 0—and the given year.
- Divide the reduced year by 4, truncate to an integer, and subtract the century number. The result is the number of leap years that have elapsed after reduced year 0 and before the given year, called the number of prior leap years.
- Add the reduced year to the number of prior leap years, divide the result by 7 and take the remainder. You will end up with a number called the dominical shift value, which is the number of days from the first Sunday of the given year to January 7 of that year. If January 7 of that year falls on a Sunday, the dominical shift value is 0.
- Convert a date in the year to its ordinal date and add the dominical shift value. Add 1 if the year chosen is a leap year and the month chosen is between March and December.
- Divide the result by 7 and take the remainder.
- The result is a number between 0 and 6 inclusive that corresponds to the day of the week of the given date in the given year, with Sunday = 0 and Saturday = 6.
Reduced to formulas, the algorithm looks like this:
To see this algorithm in action, let's find the day of the week corresponding to March 15, 1990.
- 1990 reduces to 389.
- 389 divided by 100 gives a century number of 3.
- 389 / 4 = 97.25, truncated to 97. Subtracting 3 gives 94 leap years between 1601 and 1990.
- 389 + 94 = 483, which when divided by 7 gives a remainder of 0, the dominical shift value for 1990.
- March 15 is the 74th day of 1990, a non-leap year. Adding the dominical shift value of 0 gives 74, which when divided by 7, gives a remainder of 4, which corresponds to Thursday, the day March 15, 1990 fell on.
-- Denelson83 20:01, 5 February 2011 (UTC) (amended 20:06, 17 February 2011 (UTC))
[edit] Extending the century table
Could someone extend the century table backwards to 1000 ? —Preceding unsigned comment added by 74.230.150.150 (talk) 19:58, 9 September 2007 (UTC)
- If you didn't notice, there's a pattern for centuries. You could fill it in yourself. Reywas92Talk 20:04, 9 September 2007 (UTC)
- I noticed, but before 1700 the pattern is different (due to calendar changes). I added in the new values from 1000 to 1600, however years between 1699 and 1752 are going to produce incorrect results. Someone else should check this. —Preceding unsigned comment added by 74.230.150.150 (talk) 20:24, 9 September 2007 (UTC)
- If you use 1 for 1700-1752, and 4 for 1753-1799 then everything seems to be okay. I'd appreciate it if someone else would check on this. —Preceding unsigned comment added by 74.230.150.150 (talk) 02:38, 10 September 2007 (UTC)
[edit] 209 vandal
Lots of edits have been made lately by the 209.xxx.xxx.xxx vandal. They include:
- Replacing and with &
- In the paragraph about Corresponding years, changing "...but after February, corresponds to" with simply "...and ends corresponding to". "...but after February, corresponds to" is more natural when it comes to knowing when the year changes.
- Adding "March and November" and "April and July" to the All years section. You notice that this is redundant when it comes to their locations in the Common year and Leap year sections. Georgia guy (talk) 13:29, 30 September 2008 (UTC)
[edit] Gaussian weekday algorithm source
Just to mention, I took most of it form the German WP. Richiez (talk) 12:49, 19 June 2011 (UTC)
[edit] Genuine trick to find weekday for a given date
This algorithm, developed by me (Tushar Baviskar), has no limitation at all and is the genuine way to find weekday.You just need to understand the steps thorough and you will surely be able to find day of any date ORALLY.
Suppose we have to find weekday on the date 22/04/1989. Given that current day and date is tuesday and 25/10/2011. Follow the steps given below to achieve this:
Step 1.
Find the difference between current year and specified year so 2011-1989=22
Step 2.a)
Find the number of leap years during this 22 years so 22/4=5(consider only whole number,neglect fraction)
Step 2.b)
While traversing from current year to specified year,if century is changing then check whether new century is divisible by 4 or not. In case if its not divisible by 4 then subtract 1 from the result obtained in step 2a. Here 20 is divisible by 4 hence no need to subtract 1 from 5.
Step 3.
Add the modulus of results of the above steps 1 and 2b: so 22+5=27
Step 4.
Sign convention:Now remember if we are traversing back from current year/month/date to the specified year/month/date then result will have -ve sign else if we are traversing in forward direction then result will have +ve sign.
So result is -27 since here we have reverse traversal from 2011 to 1989.
Step 5.
Remember/Calculate the following remainder corresponding to each month. For 28 day month remainder after division by 7 is 0 For 29 day month remainder after division by 7 is 1 For 30 day month remainder after division by 7 is 2 For 31 day month remainder after division by 7 is 3 Now add these remainders, for all those months, between current month and specified month, for whom we have traversed end of month. So Sept+Aug+Jul+Jun+May+Apr =2+3+3+2+3+2=15 Note that we have not considered october here since we have not traversed its end date i.e. 31st oct instead we have considered april as we have traversed its end date.
As per the sign conventions the result is -15
Step 6.
Now calculate the difference between current date and specified date 25-22=3
As per the sign conventions the result is -3
Step 7.
Now add results of steps 4,5 & 6 and divide sum by 7. So -27-15-3= -45 and -45 % 7= -3 (remainder)
Step 8.
So to get the weekday of specified date traverse in direction as specified by the sign by the remainder days (3 days back in this example) from current day Hence the answer is tuesday-3=saturday.
Give ur feedback at tush22kar@gmail.com
Tushar Baviskar, PVGian 14:23, 25 October 2011 (UTC) — Preceding unsigned comment added by Tush22kar (talk • contribs)
![f = [\frac{14 - month}{12}]](http://upload.wikimedia.org/wikipedia/en/math/7/b/9/7b964191e1b95b500c3bc337af2558df.png)
![(date + y + [\frac{31m}{12}] + [\frac{y}{4}]-[\frac{y}{100}]+[\frac{y}{400}])\operatorname{mod}7](http://upload.wikimedia.org/wikipedia/en/math/5/0/3/5034656949cb42026c22041d2a35856b.png)




