[Python-Dev] Interop between datetime and mxDateTime

Guido van Rossum guido@python.org
Mon, 13 Jan 2003 10:49:51 -0500


> I'd like to make mxDateTime and datetime in Python 2.3
> cooperate.

Me too.

There was a proposal long ago that all datetime-like objects should
implement a timetuple() method.  Perhaps we should revive that?
datetime does implement this.

> Looking at the datetime.h file, it seems that
> the C API isn't all that fleshed out yet. Will this happen
> before 2.3b1 ?

I think that datetime.h is in fact entirely private to the module.

> Related to this: I wonder why datetime is not a normal
> Python object which lives in Objects/ ?!

No single reason.  Some reasons I can think of:

- There's a pure Python implementation that can be used with Python
  2.2 (probably even earlier versions)

- It's not that essential to most code, so it seems appropriate to
  have to import it

- I didn't want this to be seen as "growing the language"

- It's still very young

> Finally, the datetime objects don't seem to provide any
> means of letting binary operations with other types
> succeed. Coercion or mixed type operations are not
> implemented. When will this happen ?

If it's up to me, never.  If you want to add a number of days,
seconds, or fortnights to a datetime, use a timedelta().  The datetime
type also supports a method to extract a posix timestamp.

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