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:01:31 +0300

> Date: Fri, 23 May 2025 22:39:51 +0900
> From: Kazuhiro Ito <[email-masked]>
> Cc: [email-masked],
> 	[email-masked]
> 
> > Do the problems mentioned in this bug happen when you use Emacs?  If
> > so, can you show a recipe which involves only Emacs, and does not
> > touch any TZ settings in the Windows Control Panel?
> 
> 1. Set timezone to Japanese Standard Time (at UTC+09:00, Osaka,
> Sapporo, Tokyo) in the Windows Control Panel.  DST option doesn't
> apprear.
> 
> 2. emacs -Q
> 
> 3. Evaluate below code.
> 
> (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.