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]]; 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 [ 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 [ 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. ” BasicTime.mesa Copyright Ó 1985, 1986, 1987, 1988, 1991 by Xerox Corporation. All rights reserved. For Portable Cedar Russ Atkinson (RRA) July 11, 1988 1:49:18 pm PDT Beach, February 27, 1985 10:17:35 am PST Doug Wyatt, January 16, 1987 5:21:52 pm PST Carl Hauser, January 19, 1988 10:18:07 am PST Errors Some conversion was given a time which could not be converted. The valid ranges are: Alto: 1901 to 2036 (232 seconds) NS: 1968 to 2103 (Alto offset to 1968) GMT: 1968 to 2036 (231 seconds, same expiry date as Alto) Unpacked: approximately forever Raised by "Now" if we don't know the time. Raised by "Unpack" if we don't know the time zone or daylight savings time information. Part I: Fine-grain timer Pulses are a machine dependent measure of elapsed time. One pulse is somewhere between 1 microseconds and 100 microseconds long. The actual pulse frequency is processor dependent. See the ProcessorFace comments. Returns the current value of the fine-grain clock Returns the number of microseconds. The calculation is careful to avoid unnecessary loss of precision. Undefined if the result would exceed 232-1 microseconds (about one hour). Returns the number of seconds. Beware: reals have only 24 bits of precision, so the fractional part of the result is not as accurate as calling PulsesToMicroseconds. However, the result never overflows. Part II: Packed times "GMT" provides a compact representation of a time, specified in seconds, which is efficient to obtain, to compare, and to modify. A value such that ~(nullGMT IN [earliestGMT..latestGMT]). Illegal as argument to most procedures. the earliest possible value of GMT (beginning of 1968) the latest possible value of GMT (sometime in 2036) The present time, if known. Raises "TimeNotKnown" if the time isn't known. The number of seconds between the times. Positive iff "to" is later than "from". Since the range of GMT is only 31 bits, the interval can always be represented in an INT. Returns the time "period" seconds later than "base" (earlier iff "period" is negative). Raises "OutOfRange" if the result would be before 1968 or after 2036. Returns time according to the Alto/Pup time standard. No errors. Returns time according to the Xerox NS protocol time standard. No errors. Accepts time according to the Alto/Pup time standard. Raises "OutOfRange" for times earlier than 1968. Accepts time according to the Xerox NS protocol time standard. Raises "OutOfRange" for times beyond about 2036. Part III: Unpacked times "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. When calling "Pack": "zone" and "dst" are either ignored or override local time parameters Remaining fields are redundant, and are always ignored by "Pack" If the local zone isn't known, assumes zone 0 and non-DST (GMT). If tp.zone=unspecifiedZone, assumes zone 0 and non-DST (GMT). Raises "TimeParametersNotKnown" if the time zone or DST info aren't sufficiently specified; raises "OutOfRange" for times before 1968 or after 2036. If unpacked.zone = unspecifiedZone, then the "zone" field of "unpacked" is ignored and the local time parameters are used; if unpacked.dst = unspcified, then DST is calculated using the local time parameters; otherwise the values from "unpacked" are used and the local values are ignored. ... provides an unpacked representation of a time period specified in seconds. Unpacks a time period specified in seconds. Returns a time period in seconds. Raises "OutOfRange" if the unpacked period is too large for an INT. Part IV: Zone/dst information Returns the currently believed local zone and DST parameters. "unspecifiedZone" is returned if they aren't currently known. Carl Hauser, January 17, 1988 3:51:10 pm PST Folded BasicTimeExtras from Cedar7.0 release in converting for Portable Cedar. Also, GetClockPulses is still commented out pending decision on how this works in Portable Cedar. Russ Atkinson (RRA) July 11, 1988 11:16:20 am PDT added calls to XR routines for GetClockPulses, PulsesToMicroseconds, PulsesToSeconds, MicrosecondsToPulses Êæ•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ ÏeœI™TKšÐbl™K™0J™(K™+K™-—K˜K˜Kšž œÏkœŸ œŸ˜$headšœ™šÏn œŸœ˜šœU™UKšœÐsuœ ™ Kšœ&™&Kšœ¡œ#™9Kšœ™—K˜—š  œŸœ˜Kšœ*™*K˜—š œŸœ˜KšœW™W—K™—™šœŸœŸœ˜KšœÖ™Ö—K˜š œŸœŸœ ˜&Kšœ1™1K˜—š œŸœ ŸœŸœ˜3Kšœ¡œ!™²K˜—š œŸœ ŸœŸœ˜.K™ÍK˜—Kš œŸœŸœŸœ ˜3K™—šœ™šŸœŸœŸœŸœ˜Kšœ™K™—šœ ŸœŸœ˜KšœŸœ˜ KšœŸœ ˜K˜K˜—š œ ŸœŸœŸœŸœ˜%KšŸœŸœD™bK˜—šœ Ÿœ˜Kšœ6™6K˜—šœ Ÿœ˜Kšœ3™3—K˜š œŸœŸœŸœ˜KšœK™KK™—š  œŸœŸœ˜+K˜—š  œŸœ ŸœŸœŸœ˜+Kšœ¬™¬K˜—š  œŸœŸœ ŸœŸœŸœ˜4Kšœž™žK˜—š   œŸœŸœŸœŸœ˜%KšœA™AK˜—š  œŸœŸœŸœŸœ˜$KšœJ™JK˜—š   œŸœŸœŸœŸœ˜'Kšœg™gK˜—š   œŸœŸœŸœŸœ˜&Kšœp™p—K˜—šœ™šœ ŸœŸœ˜Kšœè™èKšœ˜K˜!KšœÏc˜:Kšœ˜Kšœ!˜!Kšœ#˜#KšœZ™ZKšœ˜Kšœ*˜*Kšœ@™@K˜!KšœŸœŸœŸœ˜!K˜,K˜—K˜šœ Ÿœs˜„K˜—Kšœ ŸœQ˜`K˜KšœŸœ¢/˜JKšœ˜K˜KšœŸœ˜Kšœ Ÿœ˜KšœŸœ˜KšœŸœ˜Kšœ Ÿœ˜KšœŸœA˜TK˜š œŸœŸœŸœ ˜,Kšœ6ŸœŸœ™@K˜—šœP˜PK˜—š œŸœŸœ"Ÿœ ˜MKšœ3ŸœŸœ™=K™—š œŸœŸœŸœ˜.Kšœ4ŸœÿŸœ€™¹K™—K™šœŸœŸœ˜KšœN™NKšœŸœ˜Kšœ!˜!Kšœ#˜#Kšœ ŸœŸ˜K˜K™—š  œŸœ ŸœŸœ˜;K™+K™—š  œŸœŸœ Ÿœ˜9K™!Kšœ?Ÿœ™CK™——Lšœ™˜šœ ŸœŸœ˜Kšœ ˜ Kšœ¢˜8K˜—K˜š  œŸ œ˜)Kšœ|™|K˜—K˜—KšŸœ˜™,K™NK™a—™1KšœÏrœ£œ£œ£™j—K™—…—