[Pythonmac-SIG] Re: Fix for time in 1.5.2c1

Vincent Marchetti vincem@en.com
Mon, 27 Nov 2000 22:15:02 -0500


Russell Owen wrote:
-------------------------------
I'm just starting to try to read file creation times and things
aren't working as expected.
For a file created Jul 5, 2000:

>>>  ap = "RussMain:Desktop Folder:test"
>>>  ct = os.stat(ap)[stat.ST_CTIME]
>>>  ct
3045641098.0
>>>  time.localtime(ct)
(1996, 7, 6, 11, 24, 58, 5, 188, -1)
>>>  time.gmtime(ct)
(1996, 7, 6, 19, 24, 58, 5, 188, -1)

I looked back and found a discussion that was probably about this
same problem, but no solution. Any suggested patches?
...
-----------------------------------

It was unclear from the post whether you knew that this problem was fixed
in Python 2.0,
(it is), but apparently you can't use 2.0 because of Tk problems.

The solution is to add to the 'ct' variable the number of seconds in 4 years
(i.e. 4 * 365 *24 *60 *60)
Apparently, the "stat" clock is starting at Jan 1, 1904, while the
time.localtime conversion
is assuming a start date of Jan 1, 1900.

Vince Marchetti