These functions convert time values (lists of two or three integers)
to strings or to calendrical information. There is also a function to
convert calendrical information to a time value. You can get time
values from the functions current-time
(see section Time of Day) and
file-attributes
(see section Other Information about Files).
Many operating systems are limited to time values that contain 32 bits of information; these systems typically handle only the times from 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However, some operating systems have larger time values, and can represent times far in the past or future.
Time conversion functions always use the Gregorian calendar, even for dates before the Gregorian calendar was introduced. Year numbers count the number of years since the year 1 B.C., and do not skip zero as traditional Gregorian years do; for example, the year number -37 represents the Gregorian year 38 B.C.
You can also specify the field width and type of padding for any of
these `%'-sequences. This works as in printf
: you write
the field width as digits in the middle of a `%'-sequences. If you
start the field width with `0', it means to pad with zeros. If you
start the field width with `_', it means to pad with spaces.
For example, `%S' specifies the number of seconds since the minute; `%03S' means to pad this with zeros to 3 positions, `%_3S' to pad with spaces to 3 positions. Plain `%3S' pads with zeros, because that is how `%S' normally pads to two positions.
(seconds minutes hour day month year dow dst zone)
Here is what the elements mean:
t
if daylight savings time is effect, otherwise nil
.
Common Lisp Note: Common Lisp has different meanings for dow and zone.
decode-time
. It converts seven
items of calendrical data into a time value. For the meanings of the
arguments, see the table above under decode-time
.
Year numbers less than 100 are treated just like other year numbers. If
you want them to stand for years above 1900, you must alter them yourself
before you call encode-time
.
The optional argument zone defaults to the current time zone and
its daylight savings time rules. If specified, it can be either a list
(as you would get from current-time-zone
), a string as in the
TZ
environment variable, or an integer (as you would get from
decode-time
). The specified zone is used without any further
alteration for daylight savings time.
If you pass more than seven arguments to encode-time
, the first
six are used as seconds through year, the last argument is
used as zone, and the arguments in between are ignored. This
feature makes it possible to use the elements of a list returned by
decode-time
as the arguments to encode-time
, like this:
(apply 'encode-time (decode-time ...))
You can perform simple date arithmetic by using out-of-range values for the sec, minute, hour, day, and month arguments; for example, day 0 means the day preceding the given month.
The operating system puts limits on the range of possible time values; if you try to encode a time that is out of range, an error results.
Go to the first, previous, next, last section, table of contents.