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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 23 May 2025 17:16:12 +0300

> Cc: [email-masked], [email-masked]
> Date: Fri, 23 May 2025 17:01:31 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
> >   (setenv "TZ" nil)
> >   (decode-time time "est5edt"))
> > 
> > Expected result: (0 0 8 20 5 2025 2 t -14400)
> > Actual result:   (0 0 7 20 5 2025 2 t -18000)
> > 
> > As far as I tested, the result depends on whether DST is enabled in
> > the Windows Control Panel at the time of evaluating `(setenv "TZ"
> > nil)'.  In the case of Windows timezone which doesn't have DST, the
> > result is the same with unchecking DST option.
> 
> I think this is because MSVCRT routines assume that every time zone
> has DST and changes to and from DST on certain fixed dates.  IOW, they
> don't support timezones without DST and don't access the Windows
> settings for the actual timezone you are using.  So the conversion to
> EST5EDT is performed as if your timezone also had DST and the DST were
> in effect at that date.

Note that this:

  (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
    (setenv "TZ" "JST-9")
    (decode-time time "est5edt"))

yields the expected result.  That is, as long as you tell MSVCRT that
your current timezone doesn't use DST, the conversion is correct.
It's only when TZ is unset that MSVCRT time functions decide there is
DST, regardless of the actual timezone defined for Windows.