Which date will it be 'over x days'?
John Machin
sjmachin at lexicon.net
Mon Sep 18 18:15:14 EDT 2006
cyberco wrote:
> I must be overlooking something since I can't find a simple way to
> calculate which date it will be over, say, 9 days. I checked the
> datetime, time and calendar modules, but none of them seem to have a
> function to calculate the time offset.
I suppose that it depends on your thresholds for "simple" and "seem"
but datetime.timedelta() does it for me:
| >>> import datetime
| >>> datetime.date.today()
| datetime.date(2006, 9, 19)
| >>> datetime.date.today() + datetime.timedelta(days=9)
| datetime.date(2006, 9, 28)
| >>>
http://docs.python.org/lib/datetime-timedelta.html
HTH,
John
More information about the Python-list
mailing list