From: Paul Eggert <eggert@cs.ucla.edu>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 55635-done@debbugs.gnu.org, Maxim Nikulin <m.a.nikulin@gmail.com>
Subject: bug#55635: `make-decoded-time' incorrectly sets DST to nil, it should be -1 (guess)
Date: Fri, 27 May 2022 12:26:56 -0700 [thread overview]
Message-ID: <e4fdefdc-c2ea-de99-3745-66e75e6ad04c@cs.ucla.edu> (raw)
In-Reply-To: <87r14f8dhw.fsf@gnus.org>
[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]
On 5/27/22 03:40, Lars Ingebrigtsen wrote:
>> This looks wrong. Shouldn't it leave the DST flag alone? I.e., just this:
>>
>> (unless (decoded-time-zone time)
>> (setf (decoded-time-zone-time) default-zone))
>>
>> That is, if we assume that for the DST component -1 means "unknown"
>> and nil means "standard time", it should be OK for
>> decoded-time-set-defaults to leave the DST component alone, for the
>> same reason that it leaves the DOW component alone.
> Yes, I think so. But you changed this in a391ffa2f03, and you usually
> have a good reason for changes like this, so I thought there must be
> something subtle going on here I didn't quite get. 😀
Thanks for the compliment, not sure it's deserved here....
> The old code doesn't look quite right, either, I think...
>
> - ;; When we don't have a time zone and we don't have a DST, then mark
> - ;; it as unknown.
> - (when (and (not (decoded-time-zone time))
> - (not (decoded-time-dst time)))
> - (setf (decoded-time-dst time) -1))
> -
> - (when (and (not (decoded-time-zone time))
> - default-zone)
> - (setf (decoded-time-zone time) 0))
Yes, that old code was wrong because it incorrectly assumeed that (not
(decoded-time-dst time)) means the DST flag is unspecified, whereas it
really means that the DST flag is specifying standard time.
It also looked odd because default-zone was used only as a boolean, even
though its name suggests that it's the default time zone. This usage
dates back to commit fa648a59c9818ae284209ac7ae4f3700aebd92c9 which you
installed in July 2019. The only call using default-zone in Emacs is in
newsticker--decode-iso8601-date, which passes 0 so that the oddity in
the implementation makes no difference there.
Part of the confusion here is that nil doesn't mean "no time zone is
known"; it means "use the Emacs default time zone". In other words, nil
has the same interpretation problem in time zones that it has in DST
flags - it doesn't mean "unknown".
To try to lessen the confusion I installed the attached, which fixes the
reported bug so I'll close the bug report. Please feel free to revert if
you see a problem with it (I'm just trying to save time here by being bold).
[-- Attachment #2: 0001-decoded-time-set-defaults-now-leaves-DST-alone.patch --]
[-- Type: text/x-patch, Size: 1714 bytes --]
From fe38cbc14fb627f39e145b9a85f029af96f903c7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 27 May 2022 12:19:43 -0700
Subject: [PATCH] decoded-time-set-defaults now leaves DST alone
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lisp/calendar/time-date.el (decoded-time-set-defaults):
Don’t mess with decoded-time-dst (Bug#55635).
---
lisp/calendar/time-date.el | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index dc77a7c7e0..40374c3bb4 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -562,6 +562,9 @@ decoded-time-set-defaults
This year is used to guarantee portability; see Info
node `(elisp) Time of Day'.
+Optional argument DEFAULT-ZONE specifies what time zone to
+default to when TIME's time zone is nil (meaning local time).
+
TIME is modified and returned."
(unless (decoded-time-second time)
(setf (decoded-time-second time) 0))
@@ -577,13 +580,11 @@ decoded-time-set-defaults
(unless (decoded-time-year time)
(setf (decoded-time-year time) 1970))
- ;; When we don't have a time zone, default to DEFAULT-ZONE without
- ;; DST if DEFAULT-ZONE if given, and to unknown DST otherwise.
(unless (decoded-time-zone time)
- (if default-zone
- (progn (setf (decoded-time-zone time) default-zone)
- (setf (decoded-time-dst time) nil))
- (setf (decoded-time-dst time) -1)))
+ (setf (decoded-time-zone time) default-zone))
+
+ ;; Do not set decoded-time-weekday or decoded-time-dst,
+ ;; as encode-time can infer them well enough when unknown.
time)
--
2.34.1
next prev parent reply other threads:[~2022-05-27 19:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 14:46 bug#55635: `make-decoded-time' incorrectly sets DST to nil, it should be -1 (guess) Maxim Nikulin
2022-05-26 12:13 ` Lars Ingebrigtsen
2022-05-27 2:11 ` Paul Eggert
2022-05-27 10:40 ` Lars Ingebrigtsen
2022-05-27 19:26 ` Paul Eggert [this message]
2022-05-28 10:41 ` Lars Ingebrigtsen
2022-05-28 16:31 ` Maxim Nikulin
2022-05-28 16:53 ` Eli Zaretskii
2022-05-28 17:25 ` Paul Eggert
2022-05-29 13:10 ` Lars Ingebrigtsen
2022-05-29 22:04 ` Paul Eggert
2022-05-31 12:25 ` Maxim Nikulin
2022-06-13 21:30 ` Paul Eggert
2022-06-14 15:57 ` Maxim Nikulin
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=e4fdefdc-c2ea-de99-3745-66e75e6ad04c@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=55635-done@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=m.a.nikulin@gmail.com \
/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).