Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!stanford.edu!decwrl!claris!UUCP!peirce From: peirce@outpost.UUCP (Michael Peirce) Newsgroups: comp.sys.mac.programmer Subject: Re: Where is the "Time Zone" field stored? Message-ID: <0B01FFFB.ihucf6@outpost.UUCP> Date: 18 Jun 91 22:59:17 GMT Reply-To: peirce@outpost.UUCP (Michael Peirce) Organization: Peirce Software Lines: 108 X-Mailer: uAccess - Mac Release: 1.1.b3 In article <1991Jun16.054638.7152@spool.cs.wisc.edu>, elliott@veronica.cs.wisc.edu (James Elliott) writes: > > I'd like to be able to access this information in a program of mine, > and haven't been able to find any documentation that tells me where > I can read it. I suspect that it is in the parameter RAM, but it was > added after the relevant section of Inside Macintosh was printed. Can > anyone help me out here? I don't have a list of time zones (check an encyclopedia), but here is a unit that does a couple of TimeZone related things, the trick is to call ReadLocation or WriteLocation. Note: I wrote this almost a year ago and haven't really looked at it since, so caviat emptor. {------------------------------------------------------------------------------ ) M I C H E A L P E I R C E 1 9 9 0 ------------------------------------------------------------------------------} {$R-} UNIT UTimeZone; INTERFACE USES Script; CONST { The following *should* be put into a STR resource } kBeforeDirection = 'before'; kAfterDirection = 'after'; kNeitherDirection = ' '; PROCEDURE SetGMTDeltaSeconds(theSeconds : longint); FUNCTION GMTDeltaSeconds : longint; PROCEDURE GMTDelta(var directionStr,hoursStr,minutesStr : str255); IMPLEMENTATION {-----------------------------------------------------------------------------------} PROCEDURE SetGMTDeltaSeconds(theSeconds : longint); VAR location : MachineLocation; tSignedByte : SignedByte; BEGIN {GMTDeltaSeconds} ReadLocation(location); WITH location DO BEGIN tSignedByte := dlsDelta; gmtDelta := theSeconds; dlsDelta := tSignedByte; END; WriteLocation(location); END; {GMTDeltaSeconds} {-----------------------------------------------------------------------------------} FUNCTION GMTDeltaSeconds : longint; VAR location : MachineLocation; theGMTDelta : longint; BEGIN {GMTDeltaSeconds} ReadLocation(location); WITH location DO BEGIN theGMTDelta := BAND(gmtDelta,$00FFFFFF); IF BTST(theGMTDelta,23) THEN BEGIN theGMTDelta := BOR(theGMTDelta,$FF000000); END; END; GMTDeltaSeconds := theGMTDelta; END; {GMTDeltaSeconds} {-----------------------------------------------------------------------------------} PROCEDURE GMTDelta(var directionStr,hoursStr,minutesStr : str255); VAR hours,minutes, theGMTDelta : longint; BEGIN {GMTDelta} theGMTDelta := GMTDeltaSeconds; IF theGMTDelta = 0 THEN BEGIN directionStr := kNeitherDirection; hoursStr := '0'; minutesStr := '0'; END ELSE BEGIN IF theGMTDelta > 0 THEN BEGIN directionStr := kBeforeDirection; END ELSE BEGIN directionStr := kAfterDirection; theGMTDelta := ABS(theGMTDelta); END; hours := theGMTDelta DIV 3600; minutes := (theGMTDelta - (hours * 3600)) DIV 60; NumToString(hours,hoursStr); NumToString(minutes,minutesStr); END; END; {GMTDelta} END. -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE