Jump to content

Days between dates: Difference between revisions

some inline explanations
mNo edit summary
(some inline explanations)
Line 8:
https://stackoverflow.com/questions/12862226/the-implementation-of-calculating-the-number-of-days-between-2-dates
 
This example is alsosimilar to one described on the following page as the origin based algorithm, there implemented in c: http://www.sunshine2k.de/articles/coding/datediffindays/calcdiffofdatesindates.html.
 
 
Line 22:
 
def days( y,m,d ):
''' weinput shiftyear toand marchmonth withare (m*306shifted +to 5)/10begin the year in march'''
 
m = (m + 9) % 12
y = y - m/10
 
''' with (m*306 + 5)/10 the number of days from march 1 to the current 'm' month '''
result = 365*y + y/4 - y/100 + y/400 + (m*306 + 5)/10 + ( d - 1 )
return result
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.