GNU bug report logs - #52209
28.0.60; [PATCH] date-to-time fails on pure dates

Previous Next

Package: emacs;

Reported by: Bob Rogers <rogers-emacs <at> rgrjr.homedns.org>

Date: Tue, 30 Nov 2021 21:49:02 UTC

Severity: normal

Found in version 28.0.60

Full log


View this message in rfc822 format

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Bob Rogers <rogers-emacs <at> rgrjr.homedns.org>, 52209 <at> debbugs.gnu.org
Subject: bug#52209: 28.0.60; [PATCH] date-to-time fails on pure dates
Date: Fri, 03 Dec 2021 14:19:33 +0900
[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.