★ wanayoo — archive 1999 http://mail.python.org/pipermail/pythonmac-sig/2000-January/001697.htmlNouvelle recherche | Portail wanayoo

[Pythonmac-SIG] Setting Time & Date on a Macintosh

Schollnick, Benjamin Benjamin.Schollnick@usa.xerox.com
Fri, 21 Jan 2000 09:06:58 -0500


Jack,

	Here's the scoop....

	If I break every rule that I can think of it works....>g<

	Here's the code I'm using, feel free to point out any mistakes.

	Here's my notes:

	1) I suspect there is a error in the HI/LO conversion, because I am
being
		forced to add 86400, otherwise I lose a day (exactly 24 hrs
per attempt).

	2) I'd like to petition for the addition of LONGINT (or equivalent)
into
		CALLDLL.  This method will work, but I suspect sooner or
later a
		oddball value will break this.

#
# Test calldll. Tell the user how often menus flash, and let her change it.
#

import calldll
import struct
import sys
import time

epoch = 2208988800L
macadjustment = 126230400

OSUtils = calldll.getlibrary('InterfaceLib')
setmacdatetime = calldll.newcall(OSUtils.SetDateTime, 'None', 'InLong',
'InLong')
tempval = long(time.time())-macadjustment

tempval = int(tempval - 0x100000000L)
lo = int(tempval & 0xffffffff) + 86400
hi = int((tempval >> 32) & 0xffffffff)

setmacdatetime (lo, hi)

sys.exit(1)   # So the window stays on-screen

				- Benjamin