[Tutor] How do you manipulate dates? ie. one month before 1/1/2001
= ??
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Wed, 27 Jun 2001 21:36:57 -0700 (PDT)
On Thu, 28 Jun 2001, Dan Tropp wrote:
> The time module allows you to print, format and create time tuples and epoch
> time, but how do you calculate the date in two days, or three months ago
> (including rolling the months and accounting for daylight savings time??
>
> utc time - 60*60*24*numDays does not work for daylightsavings changes.
>
> I guess I'm looking for something like java.util.Calendar.add(DAY_OF_MONTH,
> numDays)
It looks like the mxDateTime module might be what you're looking for. In
the example on:
http://www.lemburg.com/files/python/mxDateTime.html
the author does examples like this:
###
# add one month
>>> print now() + RelativeDateTime(months=+1)
1998-09-11 16:46:24.59
# Last Sunday in October 1998
>>> print Date(1998) + RelativeDateTime(weekday=(Sunday,-1),month=10)
1998-10-25 00:00:00.00
###
so mxDateTime makes it easy to add and subtract dates from each
other.
Good luck to you!