DIRECTORY AMBridge USING [IsRemote, TVToLC], Commander USING [Register, CommandProc], IO USING [PutRope, STREAM], PrintTV USING [RegisterTVPrintProc, TVPrintProc], Rope USING [Cat, Substr, ROPE], Tempus USING [Packed, Unintelligible, PackedSeconds, SecondsToPacked, MakeRope, defaultTime, Parse]; TempusUtilImpl: CEDAR PROGRAM IMPORTS AMBridge, Commander, IO, PrintTV, Rope, Tempus = BEGIN OPEN Tempus; SecondsPrintProc: PrintTV.TVPrintProc = TRUSTED { -- AMBridge s: Tempus.PackedSeconds; t: Tempus.Packed; IF AMBridge.IsRemote[tv] THEN ERROR; -- shouldnt be called. TVPrintProc says can't handle remote. s _ LOOPHOLE[AMBridge.TVToLC[tv]]; t _ SecondsToPacked[s]; IF t = defaultTime THEN stream.PutRope["{current time}"] ELSE IF t=BasicTime.nullGMT THEN stream.PutRope["nullGMT"] ELSE stream.PutRope[MakeRope[time: t, precision: seconds, includeDayOfWeek: TRUE]]; }; PackedPrintProc: PrintTV.TVPrintProc = TRUSTED { -- AMBridge t: Tempus.Packed; IF AMBridge.IsRemote[tv] THEN ERROR; -- shouldnt be called. TVPrintProc says can't handle remote. t _ LOOPHOLE[AMBridge.TVToLC[tv]]; IF t = defaultTime THEN stream.PutRope["{current time}"] ELSE IF t=BasicTime.nullGMT THEN stream.PutRope["nullGMT"] ELSE stream.PutRope[MakeRope[time: t, precision: seconds, includeDayOfWeek: TRUE]]; }; WhenIs: Commander.CommandProc = { err: Rope.ROPE; t: Packed; [t, ] _ Parse[cmd.commandLine ! Unintelligible => { err _ SELECT ec FROM invalid => "Invalid", tooVague => "Too Vague", overConstrained => "Over Constrained", nothingSpecified => "Not a time", notImplemented => "Not Implemented", ENDCASE => ERROR; IF vicinity # -1 THEN err _ Rope.Cat[ err, ": ", Rope.Substr[base: rope, len: vicinity], "<>", Rope.Substr[base: rope, start: vicinity] ]; CONTINUE; }; ]; IF err # NIL THEN cmd.err.PutRope[err] ELSE cmd.out.PutRope[MakeRope[time: t, includeDayOfWeek: TRUE]]; cmd.out.PutRope["\n"]; }; PrintTV.RegisterTVPrintProc[type: CODE[Tempus.PackedSeconds], proc: SecondsPrintProc ! ANY => CONTINUE]; PrintTV.RegisterTVPrintProc[type: CODE[Tempus.Packed], proc: PackedPrintProc ! ANY => CONTINUE]; -- redefines printproc in basic system to include day of week. Commander.Register["WhenIs", WhenIs, "For testing time.parse"]; END. ’TempusUtilImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Teitelman on June 22, 1983 9:21 am Maxwell, January 5, 1984 2:12 pm Pier, May 16, 1986 2:46:46 pm PDT Rick Beach, April 4, 1985 8:17:15 am PST TRUSTED { when StoreInSymTab is implemented in CommandProcOps put this back. UserExecPrivate.StoreInSymTab[value: AMBridge.TVForReferent[NEW[Packed _ t]], event: event, exec: exec]; }; Κ4– "Cedar" style˜codešΟc™Kšœ Οmœ1™Kšœ˜K˜KšŸœŸœŸœ<˜aKšœŸœ˜"Kšœ˜KšŸœŸœ"ŸœŸœ˜sKšŸœHŸœ˜SK˜—K˜š‘œŸœŸœ ˜=K˜KšŸœŸœŸœ<˜aKšœŸœ˜"KšŸœŸœ!Ÿ œŸœ˜sKšŸœHŸœ˜SK˜K˜—K˜š‘œ˜!Kšœ Ÿœ˜K˜ šœ˜šœ˜šœŸœŸ˜Kšœ˜Kšœ˜Kšœ&˜&Kšœ!˜!Kšœ$˜$KšŸœŸ˜—šŸœŸœ˜%Kšœ˜K˜Kšœ'˜'K•StartOfExpansion9[base: ROPE, start: INT _ 0, len: INT _ 2147483647]˜K˜(Kšœ˜—KšŸœ˜ K˜—Kšœ˜—KšŸœŸœŸœ˜&KšŸœ5Ÿœ˜@Kšœ˜šŸœΟbAœ™MKšœ<Ÿœ)™hK™—Kšœ˜—K˜šœ"Ÿœ0˜VKšŸœŸœ˜—šœ"Ÿœ(˜NKšŸœŸœ>˜R—K˜K˜?—K˜K˜KšŸœ˜K˜—…—Ό ’