[futurebasic] Re: [FB] Time Zone?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Sun, 31 Jan 1999 21:51:15 -0600

James Tolchard wrote:

> Hi.
>
> I was wondering if there is there a way to get the current time difference
> from GMT using FB2.

Yep.  Here's a demo that displays your latitude, longitude, time zone
(difference from GMT in seconds), and current Daylight Savings Time status.

_machineLocation = 12
_myGmtDelta = 8
'-------------------------------------------------
LOCAL FN ReadLocation(locRecAddr&)
  'Call as follows:
  '  FN ReadLocation(@myLocn)
  'where myLocn is a 12-byte record
  `     MOVE.L  ^locRecAddr&,A0
  `     MOVE.L  #$000C00E4,D0
  `     DC.W    $A051
END FN
'-------------------------------------------------
LOCAL FN GetLocationInfo(latAddr&, longAddr&, zoneAddr&, dstAddr&)
  'Call as follows:
  '  FN GetLocationInfo(@degLat!, @degLong!, @zoneSec&, @dstFlag)
  '
  'Reads location/zone info from extended p-RAM.
  '• latitude! and longitude! are returned in degrees.
  '  Negative latitude means "south"; negative longitude means "west"
  '• The time zone is expressed as a number of seconds which
  '  should be subtracted from local Mac time to get Universal Time.
  '  Divide this by 3600 to get number of hours east of Greenwich.
  '• dstFlag will be nonzero if Daylight Savings Time is in effect.
  DIM myLocn.machineLocation
  FN ReadLocation(@myLocn)
  degLat! = 360.0 * myLocn.latitude& / (2^32)
  degLong! = 360.0 * myLocn.longitude& / (2^32)
  'Zone is actually 3 bytes, which must be sign-extended:
  zoneSec& = myLocn.myGmtDelta& AND &00FFFFFF
  IF zoneSec& AND &00800000 THEN zoneSec& = zoneSec& OR &FF000000
  dstFlag = PEEK(@myLocn + _dlsDelta)
  latAddr&.nil! = degLat!
  longAddr&.nil! = degLong!
  zoneAddr&.nil& = zoneSec&
  dstAddr&.nil% = dstFlag
END FN

FN GetLocationInfo(@degLat!, @degLong!, @zoneSec&, @dstFlag)
CLS
PRINT degLat!, degLong!
PRINT zoneSec&
PRINT dstFlag
INPUT x$
'-----------------------------

- Rick