[Pythonmac-SIG] Apple Events
Dan Green
dgreen@rewindtech.com
Fri, 14 Apr 2000 18:59:23 -0400
> > 'ldt ' (note the trailing space) is the type used by AppleScript (and
> > probably others) for the Macintosh long date type, which is a 64-bit signed
> > number of seconds since the midnight at the beginning of January 1, 1904.
> >
> > It can be easily represented in C in one of the ways the Apple headers do
> > it: an unsigned long low longword and a signed long high longword.
> >
> > Sorry, but I haven't tried dealing with it in Python...I suppose a C
> > extension could fabricate a suitable Python long integer.
>
> The struct module should be sufficient: something like
>
> import struct, time
> a, b = struct.unpack('lL', '\000\000\000\000\265\034\246\343')
> secs = long(a) << 32 + b
> print time.ctime(secs), time.asctime(time.gmtime(secs))
>
> With this string I get the values 'Mon Apr 15 10:43:47 1996' and 'Mon Apr
> 15 17:43:47 1996' respectively.
>
> You can use something like this in reverse to pack times into an Apple
> Event, too, I would guess.
>
>
> Regards,
> Corran
Interesting. When I add
if t == typeLongDate:
a, b = struct.unpack('lL', desc.data)
return long(a) << 32 + b
to aepack.py, it gives me one of these:
OverflowError: long int too long to convert
So ... ?
--
Dan Green | "So What? It's your problem to learn to live with,
Developer | destroy us, or make us saints."
Rewind Technologies | -- Ministry, "So What?"