GNU bug report logs -
#52209
28.0.60; [PATCH] date-to-time fails on pure dates
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On Wed, 01 Dec 2021 05:17:30 +0100, Lars Ingebrigtsen wrote:
> Bob Rogers <rogers-emacs <at> rgrjr.homedns.org> writes:
>> In the emacs-28 branch at 0dd3883def:
>> Imagine my surprise when evaluating
>> (days-between "2021-10-22" "2020-09-29")
>> returned zero.
> Thanks, applied to Emacs 29.
This change caused another regression. Please try:
(current-time-string (date-to-time "Fri, 03-Dec-2021 04:59:52 GMT"))
The function needs to test if `parse-time-string' returns a valid
data as the old version did it with the help of `encode-time'.
A patch is below (where why I do `(setq time ...)' is to silence
the byte compiler).
Thanks.
[Message part 2 (text/x-patch, inline)]
--- time-date.el~ 2021-12-01 22:24:35.006052000 +0000
+++ time-date.el 2021-12-03 05:13:22.832443900 +0000
@@ -158,7 +158,10 @@
(encode-time
(decoded-time-set-defaults
(condition-case err
- (parse-time-string date)
+ (let ((time (parse-time-string date)))
+ (prog1 time
+ ;; Cause an error if data `parse-time-string' returns is invalid.
+ (setq time (encode-time time))))
(error
(let ((overflow-error '(error "Specified time is not representable")))
(if (or (equal err overflow-error)
This bug report was last modified 3 years and 173 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.