[python-win32] PyTime
Mark Hammond
mhammond at skippinet.com.au
Tue May 8 16:36:41 CEST 2007
> I have an Excel file with many dates beyond 2038, which arrive to me as a
list of PyTime objects.
> From the doc I have found (
http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/PyTime.html )
> it appears that an int conversion is needed to handle them.
To answer Mark's question first, the PyTime objects predate the datetime
module by a number of years. These objects support int conversion for use
with the (effectively deprecated) time module - which does indeed suffer the
same limitations.
Your solution seems to be to simply construct a datetime object from the
pywintypes time object by way of attributes - eg:
>>> from win32com.client import Dispatch
>>> import datetime
>>> xl=Dispatch("Excel.Application")
>>> d=xl.Range("A1").Value
>>> datetime.datetime(d.year, d.month, d.day, d.hour, d.minute, d.second,
d.msec)
datetime.datetime(2065, 2, 3, 0, 0)
Cheers,
Mark
More information about the Python-win32
mailing list