Created
April 12, 2013 00:38
-
-
Save andrewjkerr/5368353 to your computer and use it in GitHub Desktop.
Uses Zeller's congruence (found here: http://en.wikipedia.org/wiki/Zeller's_congruence) to figure out which day of the week that the date is!
---
Uses python2.7!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Created on Apr 11, 2013 | |
@author: andrewkerr | |
''' | |
import math | |
input = raw_input("Enter your birthdate in a YYYY-MM-DD format:") | |
year = int(input[0:4]) | |
month = int(input[5:7]) | |
day = int(input[8:10]) | |
# Makes check for Jan/Feb | |
if month is 01 or month is 02: | |
month = month + 12 | |
year = year - 1 | |
century = year/100 | |
centuryYear = year % 100.0 | |
dayOfTheWeekNum = (day + math.floor((13 * (month + 1)) / 5) + centuryYear + math.floor(centuryYear / 4) + math.floor(century / 4) - (2 * century)) % 7 | |
days = {1: "Sunday", | |
2: "Monday", | |
3: "Tuesday", | |
4: "Wednesday", | |
5: "Thursday", | |
6: "Friday", | |
0: "Saturday", | |
} | |
print "You were born on " + input + " which is a: " + str(days[dayOfTheWeekNum]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment