#70 Allow conversion of PyTime to datetime.datetime


It would be great if you could convert PyTimes directly to datetime objects.

It would be even nicer if they *were* datetime objects, but that's a big change...


  • Roger Upole

    Roger Upole - 2008-10-31

    I'm currently working on allowing datetime.datetime objects to be used
    in place of PyTime. I've also run into the issue noted in bug #2209864
    with fractional second truncation when converting variant DATEs.

    There's also a large performance hit, since PyTime stores the value
    internally as a DATE (really a double), meaning it doesn't have to be
    converted back to a float. However, passing a datetime to/from COM becomes
    really expensive, since it will have to be converted not only
    on output, but each and every time it's passed to a function that
    needs a DATE.

    I'm considering trying to subclass datedate.datetime so we can also store
    the variant DATE with it, but haven't looked at it too deeply yet.
    In Python 2.3 datetime is pure python, but in 2.4 and up it's a
    builtin implemented in C, which may or may not support subclassing.


  • Roger Upole

    Roger Upole - 2008-10-31
    • assigned_to: nobody --> rupole
  • Vernon Cole

    Vernon Cole - 2010-05-03
    • status: open --> open-rejected
  • Vernon Cole

    Vernon Cole - 2010-05-03

    The capability to convert PyTimes to datetime already exists:...

    >>> import adodbapi
    >>> tc = adodbapi.pythonDateTimeConverter()
    >>> d = tc.DateObjectFromCOMDate(37435.7604282)
    >>> d
    datetime.datetime(2002, 6, 28, 18, 15, 0, 996480)

  • Vernon Cole

    Vernon Cole - 2010-05-03
    • status: open-rejected --> closed-out-of-date

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks