From: Ulrich Mueller <ulm@gentoo.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Eli Zaretskii <eliz@gnu.org>, 72570@debbugs.gnu.org
Subject: bug#72570: 31.0.50; Regression in date-to-time
Date: Wed, 14 Aug 2024 10:12:35 +0200 [thread overview]
Message-ID: <ucymbwmj0@gentoo.org> (raw)
In-Reply-To: <1513da6b-20a3-4033-b433-6f13b38c348d@cs.ucla.edu> (Paul Eggert's message of "Tue, 13 Aug 2024 14:19:06 -0700")
[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]
>>>>> On Tue, 13 Aug 2024, Paul Eggert wrote:
> On 2024-08-13 14:11, Ulrich Mueller wrote:
>> (Assuming that the fallback code is still needed today.
>> From commit history in the Gnus repository, it looks like the call to
>> timezone-make-date-arpa-standard was first added on 2000-01-06 in
>> https://github.com/dabrahams/gnus/commit/f1c5b21410f6e574913bbcf97ffd5e98d9ab89ac#diff-c8e4386c2f71d2573b4b5e6549e54c51cdf1fa649c6578ebd377f84e27576c93L32 .
>> The rationale for the change was to make the function "... more robust,
>> e.g. against the crop of year 100 dates in Jan 2000".)
> If that's the only reason it's there, we can simply remove the call to
> timezone-make-date-arpa-standard. That would be better to coating the
> pig with even more lipstick.
IIUC timezone-parse-date is the function that is used for parsing a date
in the fallback code. Its function documentation says:
| Understands the following styles:
| (1) 14 Apr 89 03:20[:12] [GMT]
| (2) Fri, 17 Mar 89 4:01[:33] [GMT]
| (3) Mon Jan 16 16:12[:37] [GMT] 1989
| (4) 6 May 1992 1641-JST (Wednesday)
| (5) 22-AUG-1993 10:59:12.82
| (6) Thu, 11 Apr 16:17:12 91 [MET]
| (7) Mon, 6 Jul 16:47:20 T 1992 [MET]
| (8) 1996-06-24 21:13:12 [GMT]
| (9) 1996-06-24 21:13-ZONE
| (10) 19960624T211312
I've used these to make some test cases for ERT, see the attached file.
The current date-to-time correctly handles styles 1, 2, 3, 6 (without
timezone), 7 (without timezone), 8, and 10. It returns an incorrect
result for styles 4, 5, 6 (with timezone), 7 (with timezone), and 9.
If I redefine date-to-time with the fallback code removed, the test
results are identical (somewhat surprisingly).
So I'd conclude that we don't gain much from the fallback code.
[-- Attachment #2: test-date-to-time.el --]
[-- Type: text/plain, Size: 2331 bytes --]
(ert-deftest test-date-to-time ()
;; Test cases are the formats mentioned in the docstring
;; of timezone-parse-date
(let ((date-list
'(("14 Apr 89 03:20" (00 20 03 14 04 1989 nil -1 nil))
("14 Apr 89 03:20:12" (12 20 03 14 04 1989 nil -1 nil))
("14 Apr 89 03:20 GMT" (00 20 03 14 04 1989 nil nil 0))
("14 Apr 89 03:20:12 GMT" (12 20 03 14 04 1989 nil nil 0))
("Fri, 17 Mar 89 4:01" (00 01 04 17 03 1989 nil -1 nil))
("Fri, 17 Mar 89 4:01:33" (33 01 04 17 03 1989 nil -1 nil))
("Fri, 17 Mar 89 4:01 GMT" (00 01 04 17 03 1989 nil nil 0))
("Fri, 17 Mar 89 4:01:33 GMT" (33 01 04 17 03 1989 nil nil 0))
("Mon Jan 16 16:12 1989" (00 12 16 16 01 1989 nil -1 nil))
("Mon Jan 16 16:12:37 1989" (37 12 16 16 01 1989 nil -1 nil))
("Mon Jan 16 16:12 GMT 1989" (00 12 16 16 01 1989 nil nil 0))
("Mon Jan 16 16:12:37 GMT 1989" (37 12 16 16 01 1989 nil nil 0))
("Thu, 11 Apr 16:17:12 91" (12 17 16 11 04 1991 nil -1 nil))
("Mon, 6 Jul 16:47:20 T 1992" (20 47 16 06 07 1992 nil -1 nil))
("1996-06-24 21:13:12" (12 13 21 24 06 1996 nil -1 nil))
("1996-06-24 21:13:12 GMT" (12 13 21 24 06 1996 nil nil 0))
("19960624t211312" (12 13 21 24 06 1996 nil -1 nil))
;; fails to parse time, returns 00:00:00
;("6 May 1992 1641-JST (Wednesday)"
; (00 41 16 06 05 1992 nil nil 32400))
;; parses date incorrectly as 1982-01-01
;("22-AUG-1993 10:59:12.82" (12 59 10 22 08 1993 nil -1 nil))
;; fails to parse timezone
;("Thu, 11 Apr 16:17:12 91 MET" (12 17 16 11 04 1991 nil nil 3600))
;("Mon, 6 Jul 16:47:20 T 1992 MET"
; (20 47 16 06 07 1992 nil nil 3600))
;; fails to parse time, returns 00:00:00
;("1996-06-24 21:13-JST" (00 13 21 24 06 1996 nil nil 32400))
))
(process-environment (copy-sequence process-environment))
(tz (getenv "TZ")))
(unwind-protect
(progn
(setenv "TZ" "UTC")
(dolist (date date-list)
(should (equal
(date-to-time (car date))
(encode-time (cadr date))))))
;; This is needed because setenv handles TZ specially.
;; So, restoring the environment is not enough.
(setenv "TZ" tz))))
next prev parent reply other threads:[~2024-08-14 8:12 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-11 8:57 bug#72570: 31.0.50; Regression in date-to-time Ulrich Mueller
2024-08-12 7:27 ` Ulrich Mueller
2024-08-12 8:18 ` Ulrich Mueller
2024-08-12 11:42 ` Eli Zaretskii
2024-08-12 12:51 ` Ulrich Mueller
2024-08-12 13:26 ` Eli Zaretskii
2024-08-12 13:48 ` Ulrich Mueller
2024-08-12 14:30 ` Eli Zaretskii
2024-08-12 22:03 ` Paul Eggert
2024-08-13 5:55 ` Ulrich Mueller
2024-08-13 19:39 ` Paul Eggert
2024-08-13 21:11 ` Ulrich Mueller
2024-08-13 21:19 ` Paul Eggert
2024-08-14 8:12 ` Ulrich Mueller [this message]
2024-08-14 14:09 ` Ulrich Mueller
2024-08-15 3:27 ` Paul Eggert
2024-08-15 4:35 ` Ulrich Mueller
2024-08-15 6:26 ` Paul Eggert
2024-08-15 6:45 ` Eli Zaretskii
2024-08-15 7:18 ` Ulrich Mueller
2024-08-15 7:22 ` Eli Zaretskii
2024-08-13 11:15 ` Eli Zaretskii
2024-08-13 15:09 ` Ulrich Mueller
2024-08-13 15:36 ` Eli Zaretskii
2024-08-13 19:59 ` Paul Eggert
2024-08-14 8:37 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ucymbwmj0@gentoo.org \
--to=ulm@gentoo.org \
--cc=72570@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).