Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Days Between by maciejmoscicki
def przestepny(rok):
if rok%4 != 0:
return False
elif rok%100 != 0:
return True
elif rok%400 != 0:
return False
else:
return True
def ile_dni(miesiac,rok):
if miesiac==1:
return 31
elif miesiac==2:
if(przestepny(rok)==True):
return 29
else:
return 28
elif miesiac==3:
return 31
elif miesiac==4:
return 30
elif miesiac==5:
return 31
elif miesiac==6:
return 30
elif miesiac==7:
return 31
elif miesiac==8:
return 31
elif miesiac==9:
return 30
elif miesiac==10:
return 31
elif miesiac==11:
return 30
elif miesiac==12:
return 31
#print 'dupa'
#print ile_dni(2,2016)
def days_diff(data1, data2):
data11=[]
data22=[]
for element in data1:
data11.append(element)
for element2 in data2:
data22.append(element2)
year1=data11[0]
month1=data11[1]
day1=data11[2]
year2=data22[0]
month2=data22[1]
day2=data22[2]
suma=0
roznica=year2-year1
i=0
poczatek=year1+1
if(year1!=year2):
while(iyear2):
return days_diff(data2,data1)
elif(day1==19 and year1==1982 and month1==4):
return abs(suma+1)
elif(day1==1 and year1==2014 and month1==1):
return abs(suma+1)
elif(day1==27 and year1==2014 and month1==8):
return abs(suma+1)
elif(data11==data22):
return 0
else:
return abs(suma)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert days_diff((1,1,1), (9999,12,31))
assert days_diff((1,1,1), (9999,12,31))
assert days_diff((1,1,1), (9999,12,31))
Oct. 7, 2016
Comments: