Previous: , Up: Time and Date   [Contents][Index]


5.31.3 Parsing Dates

The date Lisp library provides rudimentary support for parsing date and time descriptions to their individual components, and to timestamps. Evaluate the form (require 'date) to load this library.

Function: parse-date string #!optional start

Returns a vector encoding the date described by string. If start is defined, it specifies the index of the character in the string to start parsing from.

Each element of the vector contains a separate component of the overall point in time described by the string. The indices of these elements are defined by the following constants:

date-vec-day-abbrev

The abbreviated name of the day of the week.

date-vec-day

The numeric day of the month, counting from one.

date-vec-month-abbrev

The abbreviated name of the month.

date-vec-month

The numeric month of the year, counting from January equals one.

date-vec-year

The numeric year.

date-vec-hour

The numeric hour of the day.

date-vec-minute

The numeric minute of the hour.

date-vec-second

The numeric second of the minute.

date-vec-timezone

If true, a string defining the timezone.

date-vec-epoch-time

The timestamp (see Timestamps), including the effects of the timezone, if given.

(current-time-string)
    ⇒ "Wed Jun  2 18:37:17 1999"

(parse-date (current-time-string))
    ⇒ ["Wed" 2 "Jun" 6 1999 18 37 17 0 (10744 . 67037)]

(parse-date "1999-06-02")
    ⇒ ["Tue" 2 "Jun" 6 1999 0 0 0 0 (10744 . 0)]

(parse-date "June 6, 1999")
    ⇒ ["" 0 "Jun" 6 1999 0 0 0 0 (10742 . 0)]

(aref (parse-date "June 6, 1999") date-vec-epoch-time)
    ⇒ (10742 . 0)

XXX provide more information on accepted formats, outputs for incomplete descriptions, etc…


Previous: , Up: Time and Date   [Contents][Index]