Feature Requests item #2211970, was opened at 2008-10-31 09:05
Message generated for change (Comment added) made by kf7xm
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551957&aid=2211970&group_id=78018
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
>Resolution: Rejected
Priority: 5
Private: No
Submitted By: David Fraser (davidfraser)
Assigned to: Roger Upole (rupole)
Summary: Allow conversion of PyTime to datetime.datetime
Initial Comment:
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...
----------------------------------------------------------------------
>Comment By: Vernon Cole (kf7xm)
Date: 2010-05-03 01:55
Message:
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)
----------------------------------------------------------------------
Comment By: Roger Upole (rupole)
Date: 2008-10-31 10:51
Message:
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
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551957&aid=2211970&group_id=78018
|