Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
native_days_between solution in Clear category for Days Between by Jon_Red
def days_diff(a,b):
t=[]
for d in[a,b]:
m,y=(14-d[1])//12,d[0]-(14-d[1])//12
t.append(d[2]+(153*(d[1]+12*m-3)+2)//5+365*y+y//4-y//100+y//400)
return abs(t[0]-t[1])
if __name__=='__main__':
# self-checks
assert days_diff((1982,4,19),(1982,4,22))==3
assert days_diff((2014,1,1),(2014,8,27))==238
assert days_diff((2014,8,27),(2014,1,1))==238
July 22, 2020
Comments: