-- DateAndTimeTest.mesa
-- last edited by Levin on August 24, 1982 12:00 pm
DIRECTORY
Ascii USING [CR],
DateAndTimeUnsafe USING [Notes, Parse, Unintelligible],
Exec USING [w],
System USING [GreenwichMeanTime],
TTY USING [GetString, PutChar, PutCR, PutDate, PutDecimal, PutLongNumber, PutString];
DateAndTimeTest: PROGRAM
IMPORTS DateAndTimeUnsafe, Exec, TTY =
BEGIN
DO
s: STRING ← [100];
t: PROCEDURE [c: CHARACTER] RETURNS [yes: BOOLEAN] = {
RETURN [c = Ascii.CR]
};
gmt: System.GreenwichMeanTime;
notes: DateAndTimeUnsafe.Notes;
length: NAT;
TTY.PutString[Exec.w, "Date: "];
TTY.GetString[Exec.w, s, t];
IF s.length = 0 THEN EXIT;
[gmt, notes, length] ← DateAndTimeUnsafe.Parse[s ! DateAndTimeUnsafe.Unintelligible => {
TTY.PutString[Exec.w, " Parse failed at pos "];
TTY.PutDecimal[Exec.w, vicinity];
IF vicinity < s.length THEN {
TTY.PutString[Exec.w, "(next char is '"L];
TTY.PutChar[Exec.w, s[vicinity]];
TTY.PutString[Exec.w, "')"L];
};
TTY.PutCR[Exec.w];
LOOP}];
TTY.PutString[Exec.w, " = "];
TTY.PutLongNumber[Exec.w, gmt, [10, FALSE, TRUE, 12]];
SELECT notes FROM
noTime => TTY.PutString[Exec.w, " (no time)"];
timeAndZoneGuessed => TTY.PutString[Exec.w, " (time and zone guessed)"];
noZone => TTY.PutString[Exec.w, " (no zone)"];
zoneGuessed => TTY.PutString[Exec.w, " (zone guessed)"];
ENDCASE;
TTY.PutString[Exec.w, " = "];
TTY.PutDate[Exec.w, gmt, full];
TTY.PutCR[Exec.w];
TTY.PutString[Exec.w, " Parse stopped at position "L];
TTY.PutDecimal[Exec.w, length];
TTY.PutCR[Exec.w];
ENDLOOP;
END.