+ 1

Input a date and return the day of the week. Python code without using import. Question...

Here is my code. It only works from May 1920 to Feb 2100, because it doesn't take into account the skipping of a leap year on years divisible by 100 except on years divisible by 400 rule. Can anyone figure out how to add that? Also go backwords in time (dates before 1920)? ...I want to do it without using imports... https://code.sololearn.com/c5qdTHUA1yY2/?ref=app

23rd Dec 2018, 8:32 AM
Hobo
Hobo - avatar
1 Respuesta
+ 4
The simplest way would be to simply use Zeller's rule. Its a simple formula that can help yoi find the day of the week from a given date. You can look about it here: http://mathforum.org/library/drmath/view/62324.html But the only catch is that it works only for the gregorian calendar (i.e., for dates after 14th September, 1752) Its derivation is given here, and may help you in understanding the factor you may have left out in your own formulation. http://mathforum.org/library/drmath/view/62324.html
23rd Dec 2018, 10:18 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar