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

Fredrik Lundh fredrik@pythonware.com
Fri, 8 Feb 2002 19:04:45 +0100

I propose adding a basic time type (or time base type ;-) to the standard
library, which can be subclassed by more elaborate date/time/timestamp
implementations, such as mxDateTime, custom types provided by DB-API
drivers, etc.

The goal is to make it easy to extract the year, month, day, hour, minute,
and second from any given time object.

Or to put it another way, I want the following to work for any time object,
including mxDateTime objects, any date/timestamp returned by a DB-API
driver, and weird date/time-like types I've developed myself:

    if isinstance(t, basetime):
        # yay! it's a timestamp
        print t.timetuple()

The goal is not to standardize any behaviour beyond this; anything else
should be provided by subtypes.

More details here:


I can produce PEP and patch if necessary.