Subject: Re: bug#11281: DST has not effect on windows XP when system DST adjustment is disabled

From: Eli Zaretskii <[email-masked]>
Date: Tue, 20 May 2025 16:22:44 +0300

> Date: Tue, 20 May 2025 20:28:31 +0900
> From: Kazuhiro Ito <[email-masked]>
> 
> > > This was reported 7 years ago, but unfortunately never got a reply at
> > > the time.
> > >
> > > Is this still an issue on modern versions of Emacs?
> > 
> > More information was requested, but none was given within 39 weeks, so
> > I'm closing this bug.  If this is still an issue, please reply to this
> > email (use "Reply to all" in your email client) and we can reopen the
> > bug report.
> 
> As far as I tested, the problem still exists on master branch.
> 
> (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
>   ;; The result depends on whether DST is enabled on Windows timezone
>   ;; setting at the time of evaluating `(setenv "TZ" nil)'.
>   (setenv "TZ" nil)
>   (decode-time time "est5edt"))
> 
> ;; The case that DST is disabled on Windows control panel.
> -> (0 0 7 20 5 2025 2 t -18000)
> 
> ;; DST is enabled.
> -> (0 0 8 20 5 2025 2 t -14400)
> 
> If you start emacs with TZ environmental variable specifying timzone and
> never call (setenv "TZ" nil), the problem seems not to appear.

AFAIR, Windows implements the "traditional" time zones such as EST5
with built-in DST rules that are not synchronized with the actual DST
rules in New-York at this time, but are the old DST rules that
switched DST on and off at certain fixed dates (I no longer remember
the details, sorry).  So it is little wonder that by checking and
unchecking the DST correction in the Control Panel, one can easily
confuse what the time functions we use on Windows do, because they
need to convert the current correct time based on the actual time zone
to those "synthetic" time zones that no longer exist anywhere on
Earth.

My suggestion therefore is not to try such tricks in Emacs on Windows,
and not to expect that to produce results that are as accurate as on
Posix platforms.  The fact that you get the correct time when you use
DST checkbox that is identical to the DST flags of the time zone you
want to use is already a small wonder.

Bottom line: I don't think we should invest any effort into this dark
corner of Emacs on Windows.