<<>> <> <> <> <> <> <> <> BasicTime: CEDAR DEFINITIONS = BEGIN <> OutOfRange: ERROR; <> <> <> <> <> TimeNotKnown: ERROR; <> TimeParametersNotKnown: ERROR; <> <<>> <> Pulses: TYPE = CARD; <> GetClockPulses: PROC RETURNS [Pulses]; <> PulsesToMicroseconds: PROC [Pulses] RETURNS [CARD]; <> PulsesToSeconds: PROC [Pulses] RETURNS [REAL]; <> MicrosecondsToPulses: PROC [CARD] RETURNS [Pulses]; <<>> <> GMT: TYPE[UNITS[INT32]]; <<"GMT" provides a compact representation of a time, specified in seconds, which is efficient to obtain, to compare, and to modify.>> <<>> ExtendedGMT: TYPE = RECORD [ gmt: GMT, usecs: INT[0..1000000) ]; nullGMT: GMT = LOOPHOLE[LAST[INT32]]; <> earliestGMT: GMT; <> latestGMT: GMT; <> Now: PROC RETURNS [GMT]; <> <<>> ExtendedNow: PROC [] RETURNS [ExtendedGMT]; Period: PROC [from, to: GMT] RETURNS [INT]; <> Update: PROC [base: GMT, period: INT] RETURNS [GMT]; <> ToPupTime: PROC [GMT] RETURNS [CARD]; <> ToNSTime: PROC [GMT] RETURNS [CARD]; <> FromPupTime: PROC [CARD] RETURNS [GMT]; <> FromNSTime: PROC [CARD] RETURNS [GMT]; <> <> Unpacked: TYPE = RECORD [ <<"Unpacked" provides a representation of a time, specified in seconds, which is easy to interpret in ways meaningful to humans, such as years/months/days/etc. Each field has an default "unspecified" value for use by Time.SmartPack. >> year: [0..2050] ¬ 0, month: MonthOfYear ¬ unspecified, day: [0..daysPerMonth] ¬ 0, -- first day of the month is 1 hour: [0..hoursPerDay] ¬ 24, minute: [0..minutesPerHour] ¬ 60, second: [0..secondsPerMinute] ¬ 60, <> zone: Zone ¬ unspecifiedZone, dst: {yes, no, unspecified} ¬ unspecified, <> weekday: DayOfWeek ¬ unspecified, secondsThisYear: INT ¬ LAST[INT], daysThisYear: [0..daysPerYear] ¬ daysPerYear ]; MonthOfYear: TYPE = {January, February, March, April, May, June, July, August, September, October, November, December, unspecified}; DayOfWeek: TYPE = {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, unspecified}; Zone: TYPE = [-720..+721]; -- California is +60*8. 721 means unspecified. unspecifiedZone: Zone = +721; daysPerMonth: INT = 31; hoursPerDay: INT = 24; minutesPerHour: INT = 60; secondsPerMinute: INT = 60; daysPerYear: INT = 366; secondsPerYear: INT = secondsPerMinute * minutesPerHour * hoursPerDay * daysPerYear; Unpack: PROC [time: GMT] RETURNS [Unpacked]; <> unspecifiedTP: ZoneAndDST ~ [zone: unspecifiedZone, beginDST: 366, endDST: 366]; UnpackZ: PROC [time: GMT, tp: ZoneAndDST ¬ unspecifiedTP] RETURNS [Unpacked]; <> <<>> Pack: PROC [unpacked: Unpacked] RETURNS [GMT]; <> <<>> <<>> UnpackedPeriod: TYPE = RECORD [ <<... provides an unpacked representation of a time period specified in seconds.>> hours: INT ¬ 0, minutes: [0..minutesPerHour) ¬ 0, seconds: [0..secondsPerMinute) ¬ 0, negative: BOOL ¬ FALSE ]; <<>> UnpackPeriod: PROC [seconds: INT] RETURNS [UnpackedPeriod]; <> <<>> PackPeriod: PROC [UnpackedPeriod] RETURNS [seconds: INT]; <> <> <<>> <> ZoneAndDST: TYPE = RECORD [ zone: Zone, beginDST, endDST: [0..366] -- DST starts/stops at 2 a.m. ]; GetZoneAndDST: PROC RETURNS [ZoneAndDST]; <> END. <> <> <> <> <> <<>>