Subject: Re: bug#55635: `make-decoded-time' incorrectly sets DST to nil, it should be -1 (guess)

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 27 May 2022 12:40:43 +0200

Paul Eggert <[email-masked]> writes:

>> perhaps -1 is less "filled out" than nil in this
>> case.
>
> Indeed it is, and make-decoded-time's DST flag should default to -1.

So I've now made this change in Emacs 29.

>> It's this code, I guess:
>>    ;; 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)))
>
> 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.  😀

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))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no