Bonjour! I want to write program to calculate 28 day cycle for when rent is due, but if atthe end of year i calculate the no of days i paid the rent late , i wish to total those days and calculate them based on paid dates in my code. the question is how to insert multiplepaidDates for the whole year i.e. 12 for calculating the days i paid late? how to insert multiple arguments for it in the function datespan?
link: How to iterate over a timespan after days, hours, weeks and months in Python?
help appreciated. Merci.
from datetime import date, datetime, timedelta
def datespan(startDate, endDate, paidDate,delta=timedelta(days=1)):
currentDate = startDate
while currentDate < endDate:
yield currentDate
currentDate += delta
dl = paidDate - currentDate
print (dl)
for day in datespan(date(2015,3,12 ), date(2015,12,31), date((2015,4,15), date(2015,5,14)),
delta=timedelta(days=28)):
print (day)