[PythonCE] PyTime/DATE Variant/time module

Doug Marien doug@jarna.com
Mon, 15 Jul 2002 12:35:59 -0700


I noticed some odd behavior when extending the IContact interface for
PocketOutlook with the DATE variants.  Basically, the year/month values are
correct, but when the time module attempts to make the 1900 correction for
the year and the +1 for the month, it throws off the real time.

Starting with this code:

DATE daAnniversary;
HRESULT hr = (self->pContact)->get_Anniversary(&daAnniversary);
return PyWinObject_FromDATE(daAnniversary);

PyWinObject_FromDATE() comes from pywintypes which will return a PyTime
object.  When converting that to an integer (calling PyTime::asLong), the
year/month correction throws off the value returned which in turn throws off
the time conversion routines.

>From what I can tell, all the time routines work just fine without the
year/month correction.  Are they needed with CE?

If it is required, then in PyCE_TimeStructToSystemTime, the check for
whether the year is less than 100 will fail for anything after the year
2000.

Thoughts?

Doug Marien
doug@jarna.com