Skip to content

Instantly share code, notes, and snippets.

@TheFrostlixen
Last active December 26, 2015 23:14
Show Gist options
  • Save TheFrostlixen/52262fd8415b85fbc1b7 to your computer and use it in GitHub Desktop.
Save TheFrostlixen/52262fd8415b85fbc1b7 to your computer and use it in GitHub Desktop.
Figures out the length of time between two arbitrary days
import math
def daysInMonth(x):
return 28 + (x + math.floor(x/8)) % 2 + 2 % x + 2 * math.floor(1/x)
month = int(raw_input("month: "))
day = int(raw_input("day: "))
dmonth = int(raw_input("to (month): "))
dday = int(raw_input("to (day): "))
if dmonth > month:
dmonth += 12
sumDays = dday - day
for x in range(month, dmonth):
sumDays += daysInMonth(x)
print str(int(sumDays/7)) + " weeks " + str(int(sumDays%7)) + " days"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment