예제 #1
0
 def days_from_year_start(day, month, year):
     # copy months list twice and set the correct number of days for feb
     months = DateConvertor.months[:]
     months[1:1] = [(2, 29)] if leap_year(year) else [(2, 28)]
     prev_months = months[:month-1]
     days = day + sum(int(n) for m, n in prev_months)
     return days
예제 #2
0
 def days_upto_year_end(day, month, year):
     # copy months list twice and set the correct number of days for feb
     months = DateConvertor.months[:]
     months[1:1] = [(2, 29)] if leap_year(year) else [(2, 28)]
     days = months[month-1][1] - day
     rem_months = months[month:]
     days += sum(int(n) for m, n in rem_months)
     return days
예제 #3
0
 def days_between(self):
     days  = DateConvertor.days_upto_year_end(*self.d1)
     days += sum((366 if leap_year(y) else 365) for y in range(self.d1[2]+1, self.d2[2]))
     days += DateConvertor.days_from_year_start(*self.d2)
     return days