These functions perform calendrical computations using time values
(see Time of Day). As with any time value, a value of
nil
for any of their
time-value arguments stands for the current system time, and a finite
number stands for the number of seconds since the epoch.
This returns t
if the time value t1 is less than the time value
t2.
This returns t
if the two time values t1 and t2 are
equal. The result is nil
if either argument is a NaN.
For the purpose of comparison, a nil
argument represents the
current time with infinite resolution, so this function returns
nil
if one argument is nil
and the other is not, and
callers can therefore use nil
to represent an unknown time
value that does not equal any timestamp.
This returns the time difference t1 − t2 between
two time values, as a Lisp timestamp. The result is exact and its clock
resolution is no worse than the worse of its two arguments’ resolutions.
If you need the difference in units
of elapsed seconds, you can convert it with time-convert
or
float-time
. See Time Conversion.
This returns the sum of two time values,
using the same conversion rules as time-subtract
.
One argument should represent a time difference rather than a point in time,
as a time value that is often just a single number of elapsed seconds.
Here is how to add a number of seconds to a time value:
(time-add time seconds)
This function returns the number of days between the beginning of year 1 and time-value, assuming the default time zone. The operating system limits the range of time and zone values.
This is not quite the inverse of the time-to-days
function, as
it uses the Emacs epoch (instead of the year 1) for historical
reasons. To get the inverse, subtract (time-to-days 0)
from
days, in which case days-to-time
may return nil
if
days is negative.
This returns the day number within the year corresponding to time-value, assuming the default time zone. The operating system limits the range of time and zone values.
This function returns t
if year is a leap year.
Return the number of days in month in year. For instance, February 2020 has 29 days.
Return the date of ordinal in year as a decoded time structure. For instance, the 120th day in 2004 is April 29th.