On 2008-11-14 23:59, Victor Stinner wrote:
> Hi,
>
> There are some interresting tickets about the datetime module:
> #1673409: datetime module missing some important methods
> #1083: Confusing error message when dividing timedelta using /
> #2706: datetime: define division timedelta/timedelta
> #4291: Allow Division of datetime.timedelta Objects
>
> Wanted features:
> 1- convert a datetime object to an epoch value (numbers of seconds since
> the 1st january 1970), eg. with a new totimestamp() method
> 2- convert a timedelta to a specific unit (eg. seconds, days, weeks, etc.)
> 3- compute the ratio of two timedelta, eg. for a progress bar
Since the datetime module turned out to be mostly a reimplementation
of mxDateTime, why not continue down that road ?
http://www.egenix.com/products/python/mxBase/mxDateTime/
Let's see:
>>> from mx.DateTime import *
>>> DateTime(2008,11,15).ticks()
1226703600.0
>>> TimeDelta(seconds=100)
<mx.DateTime.DateTimeDelta object for '00:01:40.00' at 837030>
>>> TimeDelta(seconds=100) / TimeDelta(seconds=50)
2.0
>>> TimeDelta(seconds=100).seconds
100.0
>>> TimeDelta(seconds=100).days
0.0011574074074074073
>>> TimeDelta(seconds=100).weeks
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: weeks
Guess I could add a .weeks attribute to mxDateTime, but no one ever
asked for that so far.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Nov 15 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com