I have to calculate the time between two dates in days in Python, but without the datetime
module.
I managed to parse a date without datetime
:
def date(error):
global sdate
if error:
print(sdate," isn't a valable date ! ")
sdate = input('Date : ')
try:
ldate = sdate.split('.')
ldate = [ int(x) for x in ldate]
day,month,year = ldate
except ValueError:
date(True)
if year%4==0 and year%100!=0 or year%400==0:
bis = True
else:
bis = False
if month not in range(1,13):
date(True)
if month not in(1,3,5,7,8,10,12):
mmax = 31
elif month in(4,6,9,11):
mmax = 30
elif month == 2 and bis == True:
mmax = 29
elif month == 2 and bis == False:
mmax = 28
if day not in range(1,mmax+1):
date(True)
date(None)
print(ldate)
But didn't figure out how to get time between dates.
What's the easiest way?
Thanks, Blaxou
PS: It's not a Homework at all, I need it for a personal project where I use any of too easy-life-making modules ;)