Period to string [duplicate]

You need to normalize the period because if you construct it with the total number of seconds, then that’s the only value it has. Normalizing it will break it down into the total number of days, minutes, seconds, etc. Edit by ripper234 – Adding a TL;DR version: PeriodFormat.getDefault().print(period) For example: public static void main(String[] args) … Read more

Generate a list of datetimes between an interval

Use datetime.timedelta: from datetime import date, datetime, timedelta def perdelta(start, end, delta): curr = start while curr < end: yield curr curr += delta >>> for result in perdelta(date(2011, 10, 10), date(2011, 12, 12), timedelta(days=4)): … print result … 2011-10-10 2011-10-14 2011-10-18 2011-10-22 2011-10-26 2011-10-30 2011-11-03 2011-11-07 2011-11-11 2011-11-15 2011-11-19 2011-11-23 2011-11-27 2011-12-01 2011-12-05 2011-12-09 … Read more