FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MATHEMATICS

Get the time zone of the computer


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