DateAndTimeUnsafe.mesa
last edited by Levin on August 27, 1982 11:03 am
DIRECTORY
System USING [GreenwichMeanTime];
DateAndTimeUnsafe: DEFINITIONS =
BEGIN
Notes: TYPE = {normal, noZone, zoneGuessed, noTime, timeAndZoneGuessed};
Syntax of dates: The date is generally assumed to precede the time, although if the time precedes the date it will usually be properly recognized. The date syntax is a somewhat less restrictive version of RFC733; full RFC733 is recognized, plus forms like "month day, year", "mm/dd/yy", and variations with Roman numerals used for the month. The form "year month day" is also accepted if the year is a full 4-digit quantity. Forms with "-" instead of significant space are also acceptable, as well as forms in which a delimiter (space or "-") can be elided without confusion. The time is generally assumed to be in RFC733 format, with the zone specification appearing exactly as defined in that document. In addition, "am" or "pm" may optionally appear following the time (but preceding the zone, if any).
Parse: PROCEDURE [s: LONG STRING]
RETURNS [dt: System.GreenwichMeanTime, notes: Notes, length: NAT];
This procedure parses the input string and returns a GMT time according to the Pilot standard. (Note: This value is suitable without conversion as a Time.Packed.) The 'notes' return value is interpreted as follows: 'normal' means the value returned is unambiguous, 'noZone' means that a time-of-day was present, but without a zone indication (the local time zone as provided by System.LocalTimeParameters is assumed), 'zoneGuessed' is returned instead of 'noZone' if local time parameters are not available, and the zone is assumed to be Pacific Time (standard or daylight time is determined by the date). 'noTime' and 'timeAndZoneGuessed' are equivalent to 'noZone' and 'zoneGuessed', respectively, where the time is assumed to be 00:00:00 (local midnight). If the input can't be reasonably interpreted as a date, Unintelligible is raised. The 'length' return value indicates the number of characters consumed by the parser, i.e., it is the index of the first character in 's' that the parser didn't examine.
Unintelligible: ERROR [vicinity: NAT];
The parameter gives the approximate index in the input string where the parser gave up.
END.