[Pythonmac-SIG] time screwed up

Corran Webster cwebster@nevada.edu
Tue, 18 Apr 2000 09:45:38 -0700


> >>> from time import *
> >>> primt asctime(localtime(0))
> Mon Jan  1 00:00:00 1900
>
> Shouldn't that be
> Mon Jan  1 00:00:00 1904 ?

Hmmm, it looks like the current Mac time routines (at least the ones used
by Python) use 1900 as the epoch (look at your compiler's time.h for
confirmation), while the apple event system uses 1904 (which my brain says
is the start date that was used by the time routines a long time ago).
Trying the script

0 as date

in the script editor returns

date "Friday, 1 January 1904 12:00:00 AM"

which seems to confirm this.

> Anybody know how many seconds there are between 1900 and 1904? :)

>>> print asctime(localtime(4*365*24*3600))   # no leap years - whew!
Fri Jan  1 00:00:00 1904

> I knew my dates seemed off a little. :)

It seems as though the conversion routine to convert a longDateType should be:

if t == typeLongDate:
	a, b = struct.unpack('lL', desc.data)
	return (long(a) << 32) + b + 126144000

The recently modified source for aepack.py should probably be updated to
account for this.


Regards,
Corran