Next: Time Calculations, Previous: Time Conversion, Up: Time [Index]
These functions convert time values to text in a string, and vice versa. Time values include ‘nil’, numbers, and Lisp timestamps.
date-to-time
—Time String to TimestampThis function parses the time-string string and returns the corresponding Lisp timestamp.
should represent a ‘date-time’, and should be in one of the forms
recognized by parse-time-string
. This function assumes Universal Time if
string lacks explicit time zone information.
parse-time-string
—Time String to Time ListThis function parses the time-string ‘STRING’ into a list of the following form:
(sec min hour day mon year dow dst tz)
The format of this list is the same as what decode-time
accepts. Any element
that cannot be determined from the input will be set to ‘nil’.
should resemble an RFC 822 (or later) or ISO 8601 string, like “Fri, 25 Mar 2016 16:24:56 +0100” or “1998-09-12T12:21:54-0200”, but this function will attempt to parse less well-formed time strings as well.
iso8601-parse
For a more strict function (that will error out upon invalid input), this function can be used instead. It can parse all variants of the ISO 8601 standard, so in addition to the formats mentioned above, it also parses things like “1998W45-3” (week number) and “1998-245” (ordinal day number). It returns decoded time structures.
iso8601-parse-duration
Parses a duration; returns a time structure.
iso8601-parse-interval
Parse an interval; returns 3 decoded time structures: the start, the end, and the duration.
format-time-string
This function converts ‘TIME’ (or the current time, if time is omitted or ‘nil’) to a string according to ‘FORMAT-STRING’.
may contain ‘%’-sequences which say to substitute parts of the time.
One or more flag characters can appear immediately after the ‘%’.
You can also specify the field width and type of padding for any of these ‘%’-sequences.
This function uses the C library function strftime
.
format-seconds
This function converts its argument SECONDS into a string of years, days, hours, etc., according to ‘FORMAT-STRING’. The argument ‘FORMAT-STRING’ may contain ‘%’-sequences which control the conversion.
Next: Time Calculations, Previous: Time Conversion, Up: Time [Index]