<<>> <> <> <> <> <> <<>> 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.