Parse a date-and-time specification string.
Arguments and values
|string||A simple string|
|start|| Starting index into string (default is |
|end|| Ending index into string (default is |
|junk-allowed|| A generalized boolean (default is |
|date-separators|| A sequence of characters that are skipped and separate the
date, month, and year fields in string, if needed (default is
|time-separators|| A sequence of characters that are skipped and separate the
hour, minute, and second fields in string, if needed (default is
|month-precedes-date|| A generalized boolean (default is
|year-first|| A generalized boolean (default is
|default-to-current-year|| A generalized boolean (default is |
|time-first|| A generalized boolean (default is
|second||An integer between 0 and up to 59, inclusive|
|minute||An integer between 0 and up to 59, inclusive|
|hour||An integer between 0 and up to 23, inclusive|
|date||An integer between 1 and up to 31, inclusive, depending on the month and year|
|month||An integer between 1 and 12, inclusive|
|time-zone||A time zone: a rational multiple of 1/3600 between -24 and 24 that represents the number of hours offset from GMT|
|daylight-savings-p||A generalized boolean|
|position||A index in string|
Nine values: second, minute, hour, date, month, year,
If junk-allowed is false, an error is signaled if a numeric field in string does not consist entirely of the representation of a integer, possibly surrounded on either side by characters in
Both the month and date must be specified in string, optionally followed by the year and the time of day. The month can be a numeric value (1–12), a three-letter abbreviation, or the full month name. If the month is specified numerically, then the value of
nil, the current
calendar year is assumed, unless the specified month and date have passed, in
which case the next year is assumed. If no year is specified in string
nil unless a time-zone is specified
If month-precedes-date is true, the month is expected before the date; otherwise the date is expected to follow the month.
If year-first is supplied and is non-
nil, the year must be provided
and it is expected before the month and date; otherwise the year (if provided)
is expected to follow the month and date.
If a time-zone is specified in string, it is used when encoding the
If time-first is true, the time-of-day is expected before the date; otherwise the time-of-day is expected to follow the date.
The returned position is the index within string where the parse ended.
> (parse-date-and-time "1 Apr 2010") 0 0 0 1 4 2010 nil nil 10 > (parse-date-and-time "April 1, 2010 10:30") 0 30 10 1 4 2010 nil nil 19 > (parse-date-and-time "4/1/10 10:30pm") 0 30 22 1 4 2010 nil nil 14 > (parse-date-and-time "10:30pm 4/1/10" :time-first 't) 0 30 22 1 4 2010 nil nil 14 > (parse-date-and-time "Apr 1 2010 10:30 EDT") 0 30 10 1 4 2010 4 t 20 > (parse-date-and-time "1 Apr 2010 10:30 IST") 0 30 10 1 4 2010 -11/2 nil 20 > (parse-date-and-time "April 1, 2010 10:30 UTC-7") 0 30 10 1 4 2010 7 nil 25 >
The GBBopen Project