[Python-Dev] proposal: add basic time type to the standard library (original) (raw)
M.-A. Lemburg mal@lemburg.com
Sat, 09 Feb 2002 12:57:05 +0100
- Previous message: [Python-Dev] proposal: add basic time type to the standard library
- Next message: [Python-Dev] proposal: add basic time type to the standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Fredrik Lundh wrote:
mal wrote: > In order to make mxDateTime subtypes of this new type we'd need to > make sure that the datetime type uses a true struct subset of what > I have in DateTime objects now: > > typedef struct { > PyObjectHEAD > > /* Representation used to do calculations */ > long absdate; /* number of days since 31.12. in the year 1 BC > calculated in the Gregorian calendar. */ > double abstime; /* seconds since 0:00:00.00 (midnight) > on the day pointed to by absdate */ > > ...lots of broken down values needed to assure roundtrip safety... > > } as Tim has pointed out, what I have in mind is: typedef struct { PyObjectHEAD /* nothing here: subtypes should implement timetuple and, if possible, utctimetuple */ } basetimeObject; /* maybe: */ PyObject* basetimetimetuple(PyObject* self, PyObject* args) { PyErrSetString(PyExcNotImplementedError, "must override"); return NULL; } (to adapt mxDateTime, all you should have to do is to inherit from baseObject, and add an alias for your "tuple" method)
Ok.
Sounds like you are inventing something like a set of abstract types here.
I'm very much +1 on that idea, provided the interfaces we define for these types are simple enough (I think the DB SIG has shown that simple interface can go a looong way).
-- Marc-Andre Lemburg CEO eGenix.com Software GmbH
Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
- Previous message: [Python-Dev] proposal: add basic time type to the standard library
- Next message: [Python-Dev] proposal: add basic time type to the standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]