[Tutor] Help with range of months spanning across years

Sean Carolan scarolan at gmail.com
Wed Feb 2 05:00:29 CET 2011


> As far as I can tell from quickly going through documentation, no. At
> least, not with a quick and easy function. datetime can represent the
> dates just fine, and you can add days to that until you hit your end
> date, but adding months is harder. timedelta can't represent a month,
> which makes sense since they're not of constant length anyway. So
> using datetime is not really your best option. Calendar is more about
> displaying than doing calculations, making it even less useful.

Thank you, this is useful information.

>
> You can use your code or ian's (or my modification of ian's code) to
> your taste, I don't expect any measurable difference in efficiency. If
> it's really important, *measure*. But I suspect it isn't, unless
> you'll run it either on time spans of thousands of years or if it will
> be used by thousands of people at a time.

Yes, the code runs quickly enough for our needs.  Thanks again for the
helpful suggestions.


More information about the Tutor mailing list