[Python-Dev] proposal: add basic time type to the standard library

Guido van Rossum guido@python.org
Tue, 26 Feb 2002 17:53:07 -0500


> > Hm, I thought that databases have their own date/time types?  Aren't
> > these used?
> 
> At C level, interfacing is usually done using structs (ISO SQL/CLI 
> defines these).

Ah, there's another requirement that we (or at least I) almost forgot.
There should be an efficient C-level interface for the abstract
date/time type.

This stuff is hairier than it seems!  I think the main tension is
between improving upon the Unix time_t type, and improving upon the
Unix "struct tm" type.  Improving upon time_t could mean to extend the
range beyond 1970-2038, and/or extend the precision to milliseconds or
microseconds.  Improving upon struct tm is hard (it has all the
necessary fields and no others), unless you want to add operations
(just add methods) or make the representation more compact (several of
the fields can be packed in 4-6 bits each).  A third dimension might
be to provide better date/time arithmetic, but I'm not sure if there's
much of a market for that, given all the fuzzy semantics (leap
seconds, differences across DST changes, timezones).

--Guido van Rossum (home page: http://www.python.org/~guido/)