Last active
March 11, 2018 18:42
-
-
Save stonemirror/547785bcda19ccf1bc4eeb69a4ae94e7 to your computer and use it in GitHub Desktop.
Eternal September Date Calculation
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
import datetime | |
days = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"] | |
theNow = datetime.datetime.now() | |
theWeekday = days[theNow.weekday()] | |
theSeptDay = (datetime.date(theNow.year, theNow.month, theNow.day) - datetime.date(1993, 8, 31)).days | |
theLastDigit = theSeptDay % 10 | |
if theLastDigit == 1: | |
theOrdinal = "st" | |
elif theLastDigit == 2: | |
theOrdinal = "nd" | |
elif theLastDigit == 3: | |
theOrdinal = "rd" | |
else: | |
theOrdinal = "th" | |
print("Today is {}, the {}{} of SEPTEMBER, 1993".format(theWeekday, theSeptDay, theOrdinal)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment