<> <> <> <> <> <<>> DIRECTORY BasicTime, Rope USING [ROPE]; Tempus: CEDAR DEFINITIONS IMPORTS BasicTime = BEGIN OPEN BasicTime; <> Packed: TYPE = BasicTime.GMT; -- RECORD[LONG CARDINAL] PackedSeconds: TYPE = RECORD[LONG CARDINAL]; <> <> <> Seconds: TYPE = LONG CARDINAL; -- for convenience and readability defaultTime: Packed; <> Precision: TYPE = {years, months, days, hours, minutes, seconds, unspecified}; <> <> Now: PROCEDURE RETURNS [time: Packed] = INLINE { RETURN[BasicTime.Now[]]; }; PackedToSeconds: PROCEDURE [time: Packed _ defaultTime] RETURNS[PackedSeconds] = INLINE { RETURN[[BasicTime.Period[BasicTime.earliestGMT, IF time = defaultTime THEN Now[] ELSE time]]]; }; SecondsToPacked: PROCEDURE [seconds: PackedSeconds] RETURNS[time: Packed] = INLINE { RETURN[BasicTime.Update[BasicTime.earliestGMT, seconds]]; }; MakeRope: PROCEDURE [ time: Packed _ defaultTime, precision: Precision _ minutes, includeDayOfWeek: BOOL _ FALSE, useAMPM: BOOL _ TRUE ] RETURNS[value: Rope.ROPE]; <> <> <> <> SmartPack: PROCEDURE [ year: [0..2050] _ 0, month: MonthOfYear _ unspecified, day: [0..daysPerMonth] _ 0, hour: [0..hoursPerDay] _ hoursPerDay, minute: [0..minutesPerHour] _ minutesPerHour, second: [0..secondsPerMinute] _ secondsPerMinute, zone: INT _ LAST[INT], secondsThisYear: INT _ LAST[INT], daysThisYear: [0..daysPerYear] _ daysPerYear, weekday: DayOfWeek _ unspecified, baseTime: Packed _ defaultTime] RETURNS [time: Packed, precision: Precision]; <> <> <> << means "at 11:30" today, i.e. if it is earlier than 11:30 now, otherwise 11:30 tomorrow. Precision is in minutes.>> <> <> <> <> <> <> <> <> <> <> Adjust: PROCEDURE [ years: INT _ LAST[INT], months: INT _ LAST[INT], days: INT _ LAST[INT], hours: INT _ LAST[INT], minutes: INT _ LAST[INT], seconds: INT _ LAST[INT], baseTime: Packed _ defaultTime, precisionOfResult: Precision _ unspecified -- unspecified means result should be precision of smallest specified argument. ] RETURNS [time: Packed, precision: Precision]; <> <> << means in eleven hours and thirty minutes from now.>> <> << means in one month and three days from now.>> <> <> <> <> <> <> <> Parse: PROCEDURE [rope: Rope.ROPE, baseTime: Packed _ defaultTime, search: BOOL _ TRUE] RETURNS [time: Packed, precision: Precision, start, length: NAT]; <> <> <> <> <> Error: ERROR [ec: ErrorCode]; ErrorCode: TYPE = { invalid, <> overConstrained, <> tooVague, nothingSpecified, <> notImplemented <> }; Unintelligible: ERROR [rope: Rope.ROPE, vicinity: INT, ec: ErrorCode]; <> END.