PyTime.Format currently crashes with a null pointer
exception on times before 1970. (pywintypes.Time(x)
where x < -1)
In Patch 808465 I submitted a change to PyTime.Format
that used mktime and localtime to generate the day of
week and day of year since day of year is not included
in the SYSTEMTIME struct. This can crash because if the
time is before 1970 (e.g. pywintypes.Time(-10)) then
mktime returns -1 and localtime returns NULL.
This is a patch that rather does the calculations
properly (they are just numeric).
I took the code directly from the Python 2.3 datetime
module and merged in the required functions.
The resulting code is therefore simple and more reliable.