-- DMSTime.Mesa
-- edited by Brotz, August 15, 1980 10:07 AM
-- edited by Levin, May 9, 1980 4:49 PM
DIRECTORY
InlineDefs: FROM "InlineDefs",
DMSTimeDefs: FROM "DMSTimeDefs",
StringDefs: FROM "StringDefs",
TimeDefs: FROM "TimeDefs";
DMSTime: PROGRAM
IMPORTS InlineDefs, StringDefs, TimeDefs
EXPORTS DMSTimeDefs
SHARES DMSTimeDefs =
BEGIN
OPEN DMSTimeDefs, StringDefs;
quoteSpace: CHARACTER = ’ ;
MapPackedTimeToTimeZoneString: PUBLIC PROCEDURE [pt: PackedTime, s: STRING,
format: TimeFormat ← timeHouse] =
BEGIN
upt: UnpackedTime = TimeDefs.UnpackDT[pt.lc];
dayNames: ARRAY [0 .. 7) OF STRING =
["Monday"L, "Tuesday"L, "Wednesday"L, "Thursday"L,
"Friday"L, "Saturday"L, "Sunday"L];
monthNames: ARRAY [0 .. 12) OF STRING =
["Jan."L, "Feb."L, "March"L, "April"L, "May"L, "June"L,
"July"L, "Aug."L, "Sept."L, "Oct."L, "Nov."L, "Dec."L];
AppendTwoDigitNumber: PROCEDURE [v: CARDINAL, suppressZeros: BOOLEAN] =
BEGIN
d1, d2: CARDINAL;
[d1, d2] ← InlineDefs.DIVMOD[v, 10];
IF d1 ~= 0 OR ~suppressZeros THEN AppendChar[s, d1 + ’0];
AppendChar[s, d2 + ’0];
END; -- of AppendTwoDigitNumber --
AppendYear: PROCEDURE =
BEGIN
century, year: CARDINAL;
AppendChar[s, quoteSpace];
[century, year] ← InlineDefs.DIVMOD[upt.year, 100];
AppendTwoDigitNumber[century, FALSE];
AppendTwoDigitNumber[year, FALSE];
END; -- of AppendYear --
AppendHumanTime: PROCEDURE =
BEGIN
aOrP: CHARACTER ← ’a;
AppendChar[s, quoteSpace];
SELECT upt.hour FROM
< 1 => AppendTwoDigitNumber[12, TRUE];
< 12 => AppendTwoDigitNumber[upt.hour, TRUE];
= 12 => {aOrP ← ’p; AppendTwoDigitNumber[12, TRUE]};
ENDCASE => {aOrP ← ’p; AppendTwoDigitNumber[upt.hour-12, TRUE]};
AppendMinutes[];
AppendChar[s, quoteSpace];
AppendChar[s, aOrP];
AppendChar[s, ’m];
END; -- of AppendHumanTime --
AppendMinutes: PROCEDURE =
BEGIN
AppendChar[s, ’:];
AppendTwoDigitNumber[upt.minute, FALSE];
END; -- of AppendMinutes --
AppendTimeZone: PROCEDURE =
BEGIN
KnownZones: TYPE = [4..10];
zones: PACKED ARRAY KnownZones OF CHARACTER = [’A,’E,’C,’M,’P,’Y,’H];
IF upt.zone IN KnownZones THEN
BEGIN
AppendChar[s, quoteSpace];
AppendChar[s, zones[upt.zone]];
AppendChar[s, IF upt.dst THEN ’D ELSE ’S];
AppendChar[s, ’T];
END;
END; -- of AppendTimeZone --
s.length ← 0;
SELECT format FROM
timeHouse =>
BEGIN
AppendString[s, dayNames[upt.weekday]]; AppendChar[s, quoteSpace];
AppendString[s, monthNames[upt.month]]; AppendChar[s, quoteSpace];
AppendTwoDigitNumber[upt.day, TRUE];
AppendChar[s, ’,];
AppendYear[];
AppendHumanTime[];
AppendTimeZone[];
END;
laurelMsg =>
BEGIN
AppendTwoDigitNumber[upt.day, TRUE]; AppendChar[s, quoteSpace];
AppendString[s, monthNames[upt.month]];
AppendYear[];
AppendHumanTime[];
AppendTimeZone[];
AppendString[s, " ("L]; AppendString[s, dayNames[upt.weekday]]; AppendChar[s, ’)];
END;
arpaMsg =>
BEGIN
ssd: SubStringDescriptor ← [monthNames[upt.month], 0, 3];
AppendTwoDigitNumber[upt.day, TRUE]; AppendChar[s, quoteSpace];
AppendSubString[s, @ssd];
AppendYear[]; AppendChar[s, quoteSpace];
AppendTwoDigitNumber[upt.hour, FALSE];
AppendMinutes[];
AppendTimeZone[];
END;
ENDCASE;
END; -- of MapPackedTimeToTimeZoneString --
END. -- of DMSTime --