mktime, how to handle dates before 01-01-1970 ?

Stephen Hansen apt.shansen at gmail.com
Tue Oct 6 02:25:09 CEST 2009


On Mon, Oct 5, 2009 at 4:54 PM, Stef Mientki <stef.mientki at gmail.com> wrote:

> hello,
>
> I want to handle datetime vars in a general way, so I use the default
> time-format,
> so I can use the standard cinversion procedures.
>

Personally, I love mx.DateTime; its the best date/time library around. But,
Python's built in datetime isn't too bad and is similar and built-in if you
don't want to use a third-party library.

But:

>>> birthday = mx.DateTime.Date(1960,3,3)
>>> birthday
<mx.DateTime.DateTime object for '1960-03-03 00:00:00.00' at 6211e0>
>>> age = mx.DateTime.now() - birthday
>>> print "Age in days", age.days
18113.722499758693
>>> print "Age in years", age.days / 365
49.626636985640253

I really can't quite fathom why you'd want to use something so low-level as
time.mktime... or just about anything in the time module :) If you want to
handle dates in a general way, I'd use one of the general-purpose date/time
handling libraries. They're far more capable and easier to use.

HTH,

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091005/84652125/attachment.html>


More information about the Python-list mailing list