This module contains functions for basic time input and output.
format-time | [Method] |
Writes a<decoded-time>to a<stream>according to a format-string directive.
Synopsis
format-time (stream, format, time) => ()
Parameters
stream An instance of <stream>. Where the formatted time is goingformat An instance of <string>. The instructions for formatting the timetime An instance of <decoded-time>. The time instance to format
Return Values
None.
Description
Format a
<decoded-time>for output on a<stream>. The format arguments are described in the next section.
parse-time | [Function] |
Takes data on a stream and applies format arguments to
return a <decoded-time>.
Synopsis
parse-time (input, format-string) => (res)
Parameters
input An instance of <stream>. Contains input data to be convertedformat-string An instance of <string>. Contains formatting directives (described inTime-IO) to parse the data on the stream into a<decoded-time>instance.
Return Values
res An instance of <decoded-time>.
Description
Very useful function for when (e.g.) a user is asked to enter time information, or when (e.g.) reading in a text file of records which include dates or times.
Parse-timeallows the program to convert the input into a<decoded-time>instance.
This module contains two internal classes that provide information on the parse process
<parse-time-error> | [sealed Class] |
Contains the error in parsing time format directives.
Superclasses
<error>
Initialization Keywords
parse-state:An instance of <parse-state>. The<parse-state>class is described belowerror-format-string:An instance of <string>. The control string for textual error representationerror-format-args:An instance of <sequence>. The arguments to the format-string
Description
The error we signal when we have trouble parsing something. Note that an unknown format directive is *not* considered a
<time-parsing-error>, but a normal, unnamed (and close to uncatchable) error.
<parse-state> | [sealed Class] |
A parser containing the input stream, the formatting directives, and information about the status on the parse process.
Superclasses
<object> Initialization Keywords
format-string:An instance of <string>. The format-string we are trying to parse the time withformat-stream:An instance of <stream>. format-string, as a streaminput-stream:An instance of <stream>. The stream we're trying to parse
Description
This class contains several other slots containing information about the parse state:
current-directive: The directive we're currently trying to process, or #f if we're not trying to process one. Used by the error handling stuff to give informative messages.
parsed-hour: slot used when parsing 12-hour hours. Untouched when parsing 24-hour hours.
pm?: (defaults to#f), a parsed-hour helper.
parsed-day-of-year: We change this if we're asked to read in a day-of-year. Since we can't make sense of a day-of-year without knowning if it's a leap-year (and thus, knowing the year), we delay processing of this information
parsed-year: Used for processing day-of-year. The<decoded-time>doesn't actually get it's year from this slot, it gets that from the init-args.