datetime, calendar, time intervals

Michele Simionato michele.simionato at poste.it
Thu Jun 17 08:13:21 CEST 2004


Strangely enough, I never needed the datetime and calendar module
before,
so I just looked at them today. I am surprised I don't easily find an
interval
function such this:

import datetime

def interval(day, lastday, step): # not necessarely restricted to days
    while day < lastday:
        yield day
        day += step
        
firstday = datetime.date(2004, 05, 01)
lastday = datetime.date(2004, 06, 01)
oneday = datetime.timedelta(1)
for day in interval(firstday, lastday, oneday):
    print day

Did I overlook something? Has an iterator over time intervals been
taken in consideration for addition in the standard library? (or maybe
is already
there ...)
Also, the calendar module seems to be giving just the Unix "cal"
functionality
which is a  bit poor, I would have expected more ...

Just curious,

                          Michele Simionato



More information about the Python-list mailing list