[Python-ideas] Reduce platform dependence of date and time related functions
M.-A. Lemburg
mal at egenix.com
Wed Sep 18 15:34:31 CEST 2013
On 18.09.2013 15:25, random832 at fastmail.us wrote:
> On Wed, Sep 18, 2013, at 3:42, M.-A. Lemburg wrote:
>> I wonder why you'd want to use Unix ticks (what datetime calls a
>> timestamp) as basis for cross-platform date/time calculations.
>
> Because we've already got half a dozen APIs that use them. And there's
> no particular reason to consider it _worse_ than any other scalar time
> representation.
>
> If we were defining the library from scratch today, we could argue the
> merits of using days vs seconds vs microseconds as the unit, of 1970 vs
> 1904 vs 1600 vs 0000 for the epoch, and whether leap seconds should be
> supported. But we've already got APIs that use time_t (and all supported
> platforms define time_t as seconds since 1970)
Right, but those APIs are all limited to what the platforms
defines as t_time and like you say: those values are often
limited to certain ranges.
If you want platform independent representations, use one of the
available conversion routines to turn the time_t values into
e.g. datetime objects and ideally convert the values to UTC
to avoid time zone issues. Then use those objects for date/time
calculations.
time_t values are really not a good basis for doing date/time
calculations. Ideally, they should only be used and regarded
as containers holding a platform dependent date/time value,
nothing more.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Sep 18 2013)
>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2013-09-11: Released eGenix PyRun 1.3.0 ... http://egenix.com/go49
2013-09-20: PyCon UK 2013, Coventry, UK ... 2 days to go
2013-09-28: PyDDF Sprint ... 10 days to go
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
http://www.egenix.com/company/contact/
More information about the Python-ideas
mailing list