DIRECTORY BasicTime USING [earliestGMT, GMT], Rope USING [ROPE]; TimeParse: CEDAR DEFINITIONS IMPORTS BasicTime = BEGIN PieceType: TYPE = RECORD[start, len: INT]; PiecesType: TYPE = LIST OF REF PieceType; DirectionType: TYPE = {heuristic, forward, backward}; ParseErrorType: TYPE = {noTime, yearOrMonthButNoDay, yearButNoMonth, dayWeekdayMismatch, twoYears, badYearInSlash}; ParseError: ERROR[errorType: ParseErrorType]; Parse: PROC[ str: Rope.ROPE, now: BasicTime.GMT, direction: DirectionType ¬ heuristic, insistTime: BOOLEAN ¬ TRUE, insistDay: BOOLEAN ¬ TRUE] RETURNS [time: BasicTime.GMT, pieces: PiecesType ¬ NIL]; Precision: TYPE = {years, months, days, hours, minutes, seconds, unspecified}; TempusParse: PROC[ rope: Rope.ROPE, baseTime: BasicTime.GMT, search: BOOLEAN ¬ TRUE] RETURNS [time: BasicTime.GMT, precision: Precision, start, length: NAT]; 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], -- BasicTime.earliestGMT is used to mean now baseTime: BasicTime.GMT ¬ BasicTime.earliestGMT, precisionOfResult: Precision ¬ unspecified -- unspecified means result should be precision of smallest specified argument. ] RETURNS [time: BasicTime.GMT, precision: Precision]; END. F TimeParse.mesa Copyright Ó 1992 by Xerox Corporation. All rights reserved. This next bit is for backward compatibility with tempus Describes the precision of the result returned by TempusParse, and is used to specify the precision of the result returned by Adjust. In many situations, the effect of Adjust can be obtained by simply adding the appropriate seconds to the baseTime. However, "in one day" cannot be computed by simply adding 24 hours because of possibility of changeover to/from daylight saving time. Similarly, "in one month and three days" requires knowing something about how many days in that month. This is the reason for the existence of Adjust. The precision argument is used to specify the precision of the result. The resulting time is truncated (not rounded) to the corresponding precision. For example, if it is now April 28, 1983 11:20 am, Adjust[months: 1, days: 3] is May 31, 1983 12:00am, i.e. precision = days, whereas Adjust[months: 1, days: 3, precisionOfResult: minutes] is May 31, 1983 11:20am, precision = minutes. Note: Adjust will never raise an error. In particular, Adjusting from a longer month to a shorter month is handled by truncating, i.e. one month from May 31 is June 30, one month from January 29, 30 or 31 is the last day in February. Similarly, one year from February 29 is February 28. ÊY–(cedarcode) style•NewlineDelimiter ™™Jšœ Ïeœ1™