message-log-date-and-timeDate and Timeparse-date-and-timeparse-dateGoTo Top

parse-date   string &key start end junk-allowed separators month-precedes-date year-first => date, month, year, position[Function]

Purpose
Parse a date-specification string.

Package   :gbbopen-tools (home package is :module-manager)

Module   :module-manager

Arguments and values

string     A simple string
start     Starting index into string (default is 0)
end     Ending index into string (default is nil, meaning end of string)
junk-allowed     A generalized boolean (default is nil)
separators     A sequence of characters that are skipped and separate the date, month, and year fields in string, if needed (default is "-/ ,")
month-precedes-date     A generalized boolean (default is *month-precedes-date*)
year-first     A generalized boolean (default is nil)
date     An integer between 1 and up to 31, inclusive, depending on the month and year
month     An integer between 1 and 12, inclusive
year     An integer
position     A index in string

Returns
Four values: date, month, year, and position

Errors
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 separators.

Description
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 month-precedes-date is used to determine the month and date ordering. If no year is specified in string (and year-first is nil), the current year is assumed, unless the specified month and date have passed, in which case next year is assumed.

The returned position is the index within string where the parse ended.

See also
    *month-precedes-date*
    encode-date-and-time
    encode-time-of-day
    parse-date-and-time
    parse-duration
    parse-time

Examples

  > (parse-date "1 Apr 2010")
  1
  4
  2010
  10
  > (parse-date "April 1, 2010")
  1
  4
  2010
  13
  > (parse-date "Thu 1 Apr 2010")
  1
  4
  2010
  14
  > (parse-date "Thursday, April 1, 2010")
  1
  4
  2010
  23
  > (parse-date "1-4-10" :month-precedes-date 't)
  4
  1
  2010
  6
  > (parse-date "1-4-10" :month-precedes-date nil)
  1
  4
  2010
  6
  > (parse-date "4 Jul") ;; entered before July 4, 2008
  4
  7
  2008
  5
  > (parse-date "4/7  " :month-precedes-date nil)
  4
  7
  2008
  5
  > (parse-date "4/7  junk" :junk-allowed 't)
  7
  4
  2008
  5
  >

Note
This function is loaded with the :module-manager module in order to to make it available as early as possible.


The GBBopen Project


message-log-date-and-timeDate and Timeparse-date-and-timeparse-dateGoTo Top