(time-equal-p nil X) returns nil

* src/timefns.c (Ftime_equal_p): nil compares unequal to non-nil.
This commit is contained in:
Paul Eggert 2022-08-01 00:38:32 -07:00
parent 932c0bc1fc
commit 9d4633e934
2 changed files with 9 additions and 2 deletions

View file

@ -2067,7 +2067,12 @@ This returns @code{t} if the time value @var{t1} is less than the time value
@defun time-equal-p t1 t2
This returns @code{t} if the two time values @var{t1} and @var{t2} are
equal.
equal. The result is @code{nil} if either argument is a NaN.
For the purpose of comparison, a @code{nil} argument represents the
current time with infinite resolution, so this function returns
@code{nil} if one argument is @code{nil} and the other is not, and
callers can therefore use @code{nil} to represent an unknown time
value that does not equal any timestamp.
@end defun
@defun time-subtract t1 t2

View file

@ -1258,7 +1258,9 @@ DEFUN ("time-equal-p", Ftime_equal_p, Stime_equal_p, 2, 2, 0,
See `format-time-string' for the various forms of a time value. */)
(Lisp_Object a, Lisp_Object b)
{
return time_cmp (a, b) == 0 ? Qt : Qnil;
/* A nil arg compares unequal to a non-nil arg. This also saves the
expense of current_timespec if either arg is nil. */
return NILP (a) == NILP (b) && time_cmp (a, b) == 0 ? Qt : Qnil;
}