-- file: TimeDefs.Mesa
-- last edited by Sandman, June 30, 1980  5:08 PM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  InlineDefs USING [BcplLongNumber],
  MiscAlpha USING [aRCLK],
  Mopcodes USING [zMISC];

TimeDefs: DEFINITIONS =
  BEGIN

  StartWeekDay: PRIVATE INTEGER = 1; -- Jan. 1, 1901 was a Tuesday

  BaseYear: PRIVATE INTEGER = 1901;
  DaysInFourYears: PRIVATE INTEGER = 4*365 + 1;

  WestEast: TYPE = {west, east};

  LocalTimeParameters: TYPE = MACHINE DEPENDENT RECORD [
    direction: WestEast, -- Pacific is west
    zone: [0..12], -- Pacific = 8
    unused1: [0..3B],
    beginDST: [0..366], -- 121 = April 30
    unused2: [0..1B],
    zoneminutes: [0..59],
    endDST: [0..366]]; -- 305 = October 31

  currentParameters: POINTER TO LocalTimeParameters = LOOPHOLE[570B];

  currentTime: POINTER TO InlineDefs.BcplLongNumber = LOOPHOLE[572B];

  PackedTime: TYPE = LONG CARDINAL;
  DefaultTime: PackedTime = 0;

  UnpackedTime: TYPE = RECORD [
    year: [0..2050], -- base year is 1901
    month: [0..12), -- January = 0
    day: [0..31], -- first day of month = 1
    hour: [0..24),
    minute: [0..60),
    second: [0..60),
    weekday: [0..6], -- Monday = 0
    zone: [-12..12],
    dst: BOOLEAN];

  CurrentDayTime: PROCEDURE RETURNS [time: PackedTime];
  UnpackDT: PROCEDURE [p: PackedTime ← DefaultTime] RETURNS [time: UnpackedTime];
  InvalidTime: ERROR;
  PackDT: PROCEDURE [unp: UnpackedTime, computeDST: BOOLEAN ← TRUE]
    RETURNS [time: PackedTime];
  AppendDayTime: PROCEDURE [s: STRING, unp: UnpackedTime, zone: BOOLEAN ← FALSE];
  -- 12-JAN-77 12:34:56

  AppendFullDayTime: PROCEDURE [s: STRING, unp: UnpackedTime] = INLINE
    BEGIN AppendDayTime[s, unp, TRUE]; END;

  -- 12-JAN-77 12:34:56 PST

  RealTimeClock: POINTER TO CARDINAL = LOOPHOLE[430B];
  ReadClock: PROCEDURE RETURNS [LONG UNSPECIFIED] = MACHINE CODE
    BEGIN Mopcodes.zMISC, MiscAlpha.aRCLK END;


  END...