[Tutor] is mxDateTime recommended?
Kent Johnson
kent37 at tds.net
Sat Oct 22 14:07:26 CEST 2005
Lance E Sloan wrote:
> --On Thursday, October 20, 2005 4:44 PM -0400 Kent Johnson
> <kent37 at tds.net> wrote:
>
>> Since 2.3 Python includes a datetime module which has some facility for
>> date calculations. I think mxDateTime is more sophisticated but if your
>> needs are simple take a look at datetime.
>
>
> I think I would like to use the "datetime" module included with Python,
> just so I don't need to worry about an additional piece of code, the
> "mxDateTime" module.
>
> In my code, I set up some mxDateTime RelativeDateTime objects that will
> be used later:
>
> secondLockBeginsDelta = DateTime.RelativeDateTime( day = 14, hour = 23,
> minute = 59, months = -4 )
You might want to look at dateutils, it can do this. It is an add-on module but it is pure Python.
http://labix.org/python-dateutil
>>> from datetime import *; from dateutil.relativedelta import *
>>> firstTime = datetime.now()
>>> offset = relativedelta(day = 14, hour = 23, minute = 59, months = -4 )
>>> firstTime+offset
datetime.datetime(2005, 6, 14, 23, 59, 4, 209000)
Kent
More information about the Tutor
mailing list