GNU bug report logs - #11281
DST has not effect on windows XP when system DST adjustment is disabled

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Shuguang Sun <shuguang@HIDDEN>; Done: Stefan Kangas <stefan@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 26 May 2025 15:02:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 26 11:02:49 2025
Received: from localhost ([127.0.0.1]:58008 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJZLk-0000jO-Sd
	for submit <at> debbugs.gnu.org; Mon, 26 May 2025 11:02:49 -0400
Received: from mta-snd-e06.auone-net.jp ([111.86.247.6]:30625)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uJZLg-0000ir-QY
 for 11281 <at> debbugs.gnu.org; Mon, 26 May 2025 11:02:47 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e06.auone-net.jp with ESMTP
 id <20250526150241440.OBCY.54425.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Tue, 27 May 2025 00:02:41 +0900
Date: Tue, 27 May 2025 00:02:41 +0900
Message-ID: <8534crwh2m.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <855xhnwmd5.wl--xmue@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN> <86h61b4hxg.fsf@HIDDEN>
 <85y0un5tug.wl--xmue@HIDDEN> <86ecwf4e9w.fsf@HIDDEN>
 <86cybz4dlf.fsf@HIDDEN> <85wma6632h.wl--xmue@HIDDEN>
 <86y0um2zoz.fsf@HIDDEN> <858qmkx5gg.wl--xmue@HIDDEN>
 <86iklozvd5.fsf@HIDDEN> <857c24wwwo.wl--xmue@HIDDEN>
 <86h618zo2d.fsf@HIDDEN> <855xhnwmd5.wl--xmue@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748271761; 
 bh=TFmc1WGNDa0iXevJGZl25KGuWjgdDYRrV2KkobepjEg=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=K65TMmUPMZOUfHD5Bg3+VbtYT0816De1cdnJkb/I8TxjGngmm/jH+p8rSzLq/5XvwQf92xX1
 EmBJv1CQMEUnt2cgY7+SmcKoDdVTMS5eO3sP31TD7ciVbpWokRI1JKctIOikf5VuFPmTVdk1ts
 9UN6QOJsdPM7ICvDFkU0Sur+gvkMIiXzMaz87XpJWOaXE9hOPOQUOLl5/g1C8UxWwGGmHLBnMq
 qlSKWc6QlJUf8/C+6XWjMNp6OLLnE712sseqDog3++Ptzr7N9GX5bvk9B5CDHIp03jAzPuFCkM
 CLGL6Bi66aQ6cYTrFKbEdUOT/BLey+oEzVPF2gnWr3Q4CXEQ==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > See above: I think I changed my mind, and we should set _dstbias
> > according to the actual value of TZ, and only if TZ is indeed set
> > (because I think if TZ is not set, MSVCRT gets the correct value from
> > GetTimeZoneInformation).  Can you try that and see if it improves the
> > current situation?
> 
> Please see attached patch.  I think we don't need to re-parse TZ value
> because it is already parsed by tzset and the result is set to
> _daylight variable.

I posted it before reading your patch, so please ignore it

> In addition, I noticed there is a code that calls
> tztest and needs the same workaoround on Windows in lib/time_rz.c,
> however I don't know how to apply the change only on Windows.  Please
> see the second patch.

I can't reproduce the problem with your patch.  I think I was somewhat
confused.  However I'm not sure tzset call in lib/time_rz.c is really
safe.  I'll post if I found the problem not fixed.  Sorry for noise.

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 26 May 2025 14:51:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 26 10:51:02 2025
Received: from localhost ([127.0.0.1]:57923 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJZAL-0008HR-Ny
	for submit <at> debbugs.gnu.org; Mon, 26 May 2025 10:51:02 -0400
Received: from mta-snd-e07.auone-net.jp ([111.86.247.7]:28129)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uJZAF-0008Gm-OJ
 for 11281 <at> debbugs.gnu.org; Mon, 26 May 2025 10:50:58 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e07.auone-net.jp with ESMTP
 id <20250526145052202.NZMX.75697.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Mon, 26 May 2025 23:50:52 +0900
Date: Mon, 26 May 2025 23:50:51 +0900
Message-ID: <854ix7whmc.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86bjrfzi5u.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN> <86h61b4hxg.fsf@HIDDEN>
 <85y0un5tug.wl--xmue@HIDDEN> <86ecwf4e9w.fsf@HIDDEN>
 <86cybz4dlf.fsf@HIDDEN> <85wma6632h.wl--xmue@HIDDEN>
 <86y0um2zoz.fsf@HIDDEN> <858qmkx5gg.wl--xmue@HIDDEN>
 <86iklozvd5.fsf@HIDDEN> <857c24wwwo.wl--xmue@HIDDEN>
 <86h618zo2d.fsf@HIDDEN> <86bjrfzi5u.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748271052; 
 bh=TrQYU9MY88p7Y8xqZMi1rGx/ZG/0aY09dfdFi+ILarQ=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=eXiQAQfPTEB2B8jMqCGVdBd4dbBKphqaopOOwYKVBHJXLPEcXfVxJg8TihpZe8oB8kutd+B/
 zzOYjAYwsJFOoIXWspYkKKSezyfzCCzZZiq+M/wSVjVKo0EBRX+XlN09aotxnue5qfni56bDJv
 J36i2upfbJw+IZ2n7IqurlT/weCj6cL1U6anm7uX2p3OSofG6uunx6Kwca3P9uABeTDdczfJFC
 6swuaLCroS1kxIqbLHA9jWo8G1Iz4uEfuVWH7ObvYPmiprkeRm6RKQWAka8Cqf+TET6bmUl69l
 UXrIsO+0YXivztYYxGADxMMFTXCUADEHmWdsgfRnr8krTb6Q==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> I think I see the problem: when TZ is defined in the environment,
> tzset updates _daylight, but doesn't touch _dstbias.  So if you start
> from a timezone without DST and then switch to a timezone with DST,
> _dstbias stays zero, and local time is computed incorrectly.
> 
> Therefore, I suggest the patches below.  Could you please try them?

As far as I tested, the issue is resolved.
Thank you!

> diff --git a/src/w32.c b/src/w32.c
> index 5de721a..a98a008 100644
> --- a/src/w32.c
> +++ b/src/w32.c
> @@ -10289,6 +10289,30 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname)
>  }
>  
>  
> +/* mingw.org's MinGW doesn't declare _dstbias.  MinGW64 defines it as a
> +   macro.  */
> +#ifndef _dstbias
> +__MINGW_IMPORT int _dstbias;
> +#endif
> +
> +/* Fix a bug in MS implementation of 'tzset', to be called immediately
> +   after 'tzset'.  */
> +void
> +w32_fix_tzset (void)
> +{
> +  char *tz_env = getenv ("TZ");
> +
> +  /* When TZ is defined in the environment, '_tzset' updates _daylight,
> +     but not _dstbias.  Then if we are switching from a timezone without
> +     DST to a timezone with DST, 'localtime' and friends will apply zero
> +     DST bias, which is incorrect. (When TZ is not defined, '_tzset'
> +     does update _dstbias using values obtained from Windows API
> +     GetTimeZoneInformation.)  Here we fix that blunder by detecting
> +     this situation and forcing _dstbias to be 1 hour.  */
> +  if (tz_env && _daylight && !_dstbias)
> +    _dstbias = -3600;
> +}

You wrote _dstbias should be zero when _daylight was zero, but the
patch doesn't touch _dstbias in that case.  However it whould not
cause a real problem as I wrote.

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 26 May 2025 13:08:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 26 09:08:38 2025
Received: from localhost ([127.0.0.1]:55999 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJXZG-0005iJ-5M
	for submit <at> debbugs.gnu.org; Mon, 26 May 2025 09:08:38 -0400
Received: from mta-snd-e09.auone-net.jp ([111.86.247.9]:60480)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uJXZ4-0005hL-QD
 for 11281 <at> debbugs.gnu.org; Mon, 26 May 2025 09:08:30 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e09.auone-net.jp with ESMTP
 id <20250526130822632.NYSI.117557.kzhr.d1.dion.ne.jp@HIDDEN>;
 Mon, 26 May 2025 22:08:22 +0900
Date: Mon, 26 May 2025 22:08:22 +0900
Message-ID: <855xhnwmd5.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86h618zo2d.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>	<858qmkx5gg.wl--xmue@HIDDEN>	<86iklozvd5.fsf@HIDDEN>	<857c24wwwo.wl--xmue@HIDDEN>	<86h618zo2d.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: multipart/mixed; boundary="Multipart_Mon_May_26_22:08:22_2025-1"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748264902; 
 bh=ue7fsA4EHXWZgc/+cg9ZGSE7koeR37AIbQnBtqSn0Yk=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=kTiW+6yHMNUN+C9phUpeNEcGDL/p63ubHNDYjPUKVTGbLkcpWp+RadXdEYfaFbcWTOo12pyD
 aXdqncAc/Z+JnhshGzt/wFfgHeY1Nvvt8r0XA++Y8OucgU6w9UYYGJOMpdRPlLiE0f68mJkDBA
 a9N84lhDiI2lwu4pqLWSs4WTxMAsZ5vApOq48wpca/LY6gVoGN5jwf1VQM7TOjjLHfuJUNFD+z
 tTOxdfxMd6PLNdMLt/4RoeoFfSAjho5vtCX5FB5gr12xQ+G05Oi+Ja9kGjxbUCmVcwM1qKLYXJ
 dObPsqjwHRWvWXmMckudTgPF9BkOqjYN9B+oQ99/r8NDBcKQ==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Multipart_Mon_May_26_22:08:22_2025-1
Content-Type: text/plain; charset=ISO-2022-JP

> > Please see the
> > result of 2nd est5edt, where _dstbias is zero and _daylight is
> > non-zero, which causes the issue.  I guess the first -3600 is probably
> > initial value because Microsoft says that initial values are for
> > "PST8PDT".
> 
> I can understand this in your case, since your timezone doesn't
> specify DST.  Can you show me what the GetTimeZoneInformation API
> returns on your system with your default timezone?

I tried with following code.

#include <stdio.h>
#include <windows.h>

void printSYSTEMTIME (const char *name, LPSYSTEMTIME time) {
  printf("%s is %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
	 name, time->wYear, time->wMonth, time->wDayOfWeek,
	 time->wDay, time->wHour, time->wMinute, time->wSecond,
	 time->wMilliseconds);
}

int main (int argc, wchar_t* argv[]) {
  TIME_ZONE_INFORMATION timezone;

  DWORD result = GetTimeZoneInformation(&timezone);

  printf ("Return code is %d\n", result);
  printf ("Bias is %ld\n", timezone.Bias);
  wprintf (L"StandardName is %s\n", timezone.StandardName);
  printSYSTEMTIME("StandardDate", &timezone.StandardDate);
  printf ("StandardBias is %ld\n", timezone.StandardBias);
  wprintf (L"DaylightName is %s\n", timezone.DaylightName);
  printSYSTEMTIME("StandardDate", &timezone.DaylightDate);
  printf ("DaylightBias is %ld\n", timezone.DaylightBias);

  return 0;
}

result:
Return code is 0
Bias is -540
StandardName is 東京 (in utf-16-le)
StandardDate is 0, 0, 0, 0, 0, 0, 0, 0
StandardBias is 0
DaylightName is 東京 (in utf-16-le)
StandardDate is 0, 0, 0, 0, 0, 0, 0, 0
DaylightBias is 0

result on Eastern Standard Time:
Return code is 2
Bias is 300
StandardName is 東部標準時 (in utf-16-le)
StandardDate is 0, 11, 0, 1, 2, 0, 0, 0
StandardBias is 0
DaylightName is 東部夏時間 (in utf-16-le)
StandardDate is 0, 3, 0, 2, 2, 0, 0, 0
DaylightBias is -60

> > > Sorry, I don't think I understand: AFAIU, _dstbias can legitimately be
> > > zero in timezones that don't support DST.  If that is true, correcting
> > > a zero-valued _dstbias to 1 hour will cause problems, no?
> > > should also look at the value of _daylight, and only do the _dstbias
> > > correction of _daylight is zero (i.e. no DST in this timezone)?  Or
> > > what am I missing?
> > 
> > I agree with you that _dstbias should be zero when _daylight is zero.
> > However, as I wrote above, _dstbias should not be used when _daylight
> > is zero.  My emacs has set TZ to JST-9 long time and _dstbias has been
> > -3600 according to my test.  It has no problem till now.  So I removed
> > _daylight value check before posting the patch, but If you mind,
> > correcting _dstbias only when _daylight is *NON-ZERO* (not _daylight
> > is zero!) should be okay.
> 
> See above: I think I changed my mind, and we should set _dstbias
> according to the actual value of TZ, and only if TZ is indeed set
> (because I think if TZ is not set, MSVCRT gets the correct value from
> GetTimeZoneInformation).  Can you try that and see if it improves the
> current situation?

Please see attached patch.  I think we don't need to re-parse TZ value
because it is already parsed by tzset and the result is set to
_daylight variable.  In addition, I noticed there is a code that calls
tztest and needs the same workaoround on Windows in lib/time_rz.c,
however I don't know how to apply the change only on Windows.  Please
see the second patch.


--
Kazuhiro Ito

--Multipart_Mon_May_26_22:08:22_2025-1
Content-Type: text/plain; type=patch; name="0001-Adjust-_dstbias-value-after-tzset-on-Windows.patch"; charset=US-ASCII
Content-Disposition: attachment; filename="0001-Adjust-_dstbias-value-after-tzset-on-Windows.patch"
Content-Transfer-Encoding: 7bit

From 34edab6204b74016ed90ee816bb17ee58f0236b8 Mon Sep 17 00:00:00 2001
From: Kazuhiro Ito <kzhr@HIDDEN>
Date: Sun, 25 May 2025 20:04:48 +0900
Subject: [PATCH 1/2] Adjust _dstbias value after tzset on Windows

The Windows CRT implementation of 'tzset' does't seem to adjust
_dstbias when timezone is specified by TZ environmental variable.
(Bug#11281)

* src/w32.c (sys_tzset): New function.  Adjust _dstbias value
after tzset.
* src/timefns.c (emacs_localtime_rz): Use it on Windows.
---
 src/timefns.c |  7 ++++++-
 src/w32.c     | 12 +++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/timefns.c b/src/timefns.c
index 4d296ff8dcd..d1304328e11 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -42,6 +42,7 @@ Copyright (C) 1985-1987, 1989, 1993-2025 Free Software Foundation, Inc.
 
 #ifdef WINDOWSNT
 extern clock_t sys_clock (void);
+extern void sys_tzset (void);
 #endif
 
 #ifdef HAVE_TIMEZONE_T
@@ -188,7 +189,7 @@ emacs_localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
      So all Emacs features that repeatedly call time functions (e.g.,
      display-time) are in real danger of missing timezone and DST
      changes.  Calling tzset before each localtime call fixes that.  */
-  tzset ();
+  sys_tzset ();
 #endif
   tm = localtime_rz (tz, t, tm);
   if (!tm && errno == ENOMEM)
@@ -305,7 +306,11 @@ tzlookup (Lisp_Object zone, bool settz)
     {
       block_input ();
       emacs_setenv_TZ (zone_string);
+#ifndef WINDOWSNT
       tzset ();
+#else
+      sys_tzset ();
+#endif
       timezone_t old_tz = local_tz;
       local_tz = new_tz;
       tzfree (old_tz);
diff --git a/src/w32.c b/src/w32.c
index 5de721ad71f..7fcf08d5ba2 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -84,6 +84,7 @@ #define DEFER_MS_W32_H
 int sys_read (int, char *, unsigned int);
 int sys_write (int, const void *, unsigned int);
 struct tm *sys_localtime (const time_t *);
+void sys_tzset (void);
 /* MinGW64 system headers include string.h too early, causing the
    compiler to emit a warning about sys_strerror having no
    prototype.  */
@@ -10289,6 +10290,15 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname)
 }
 
 
+/* The Windows CRT implementation of 'tzset' does't seem to adjust
+   _dstbias when timezone is specified by TZ environmental variable. */
+void sys_tzset (void) {
+  tzset ();
+
+  if(getenv ("TZ"))
+    _dstbias = _daylight ? -3600 : 0;
+}
+
 /* The Windows CRT functions are "optimized for speed", so they don't
    check for timezone and DST changes if they were last called less
    than 1 minute ago (see http://support.microsoft.com/kb/821231).  So
@@ -10298,7 +10308,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname)
 struct tm *
 sys_localtime (const time_t *t)
 {
-  tzset ();
+  sys_tzset ();
   return localtime (t);
 }
 
-- 
2.45.1


--Multipart_Mon_May_26_22:08:22_2025-1
Content-Type: text/plain; type=patch; name="0002-lib-time_rz.c-change_env-Sample-workaround-for-Windo.patch"; charset=US-ASCII
Content-Disposition: attachment; filename="0002-lib-time_rz.c-change_env-Sample-workaround-for-Windo.patch"
Content-Transfer-Encoding: 7bit

From 60f07d0d6fc39ded444cc0bb23b75bf3290fa2ad Mon Sep 17 00:00:00 2001
From: Kazuhiro Ito <kzhr@HIDDEN>
Date: Mon, 26 May 2025 20:52:59 +0900
Subject: [PATCH 2/2] * lib/time_rz.c (change_env): Sample workaround for
 Windows

---
 lib/time_rz.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/time_rz.c b/lib/time_rz.c
index 125f4e272d2..1ce6e76b18b 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -190,6 +190,8 @@ change_env (timezone_t tz)
   if (setenv_TZ (tz->tz_is_set ? tz->abbrs : NULL) != 0)
     return false;
   tzset ();
+  if (getenv("TZ"))
+    _dstbias = _daylight ? -3600 : 0;
   return true;
 }
 
-- 
2.45.1


--Multipart_Mon_May_26_22:08:22_2025-1--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 26 May 2025 12:11:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 26 08:11:07 2025
Received: from localhost ([127.0.0.1]:55596 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJWfa-0001Z0-R4
	for submit <at> debbugs.gnu.org; Mon, 26 May 2025 08:11:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:50978)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uJWfX-0001YP-4s
 for 11281 <at> debbugs.gnu.org; Mon, 26 May 2025 08:11:04 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uJWfP-0007jL-4n; Mon, 26 May 2025 08:10:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=IdkPLiz4C4YOCI8O0ian4Uzt4g+yjnT/QWk7HfWyhEQ=; b=Xv0TRzlHYyHi
 pQpQ1MNuu+bPCiENqcSkrqJiPPVWOH6HZo+rShQPoeYZOvvz2gmT5bLBo+xm8pWfGrhNMTcrW9cdf
 HaECm6QwbpF9Hc6wFRt5agnnmbG7qGBFXnJo+r5aLC5WFhRFnBexEMMuYsyO6k0LEr5rZvaDDxhht
 bioyUOV23P06wOTTXfwrHpq/7sissezbg8iYph4hwJXorg53buOtEs3WHHw9HQ74Y4CGEzkVEsppA
 7/1+UO0tOBNeWCgH5JRTwXGPIWTGO1co2FL1EKztdT2+GkTkKM+d37ihe2rhVmpL4hQVEO4OndJX5
 ll0nyw5ssWzwdXjB6RBrsg==;
Date: Mon, 26 May 2025 15:10:53 +0300
Message-Id: <86bjrfzi5u.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: kzhr@HIDDEN
In-Reply-To: <86h618zo2d.fsf@HIDDEN> (message from Eli Zaretskii on Sun, 25
 May 2025 18:51:06 +0300)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>	<858qmkx5gg.wl--xmue@HIDDEN>	<86iklozvd5.fsf@HIDDEN>
 <857c24wwwo.wl--xmue@HIDDEN> <86h618zo2d.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> Date: Sun, 25 May 2025 18:51:06 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> > Date: Mon, 26 May 2025 00:08:23 +0900
> > From: Kazuhiro Ito <kzhr@HIDDEN>
> > Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> > 
> > > > > JST-9
> > > > > _daylight = 0
> > > > > _timezone = -32400
> > > > > _tzname[0] = JST
> > > > > _dstbias = -3600
> > > 
> > > Isn't this result strange?  If a timezone has no DST, why is _dstbias
> > > not zero?
> > 
> > I feel it is strange, too.  My understanding is that tzset does not
> > touch _dstbias when timezone is specified by TZ environmental variable
> > and it is the bug.  However when _daylight is zero, _dstbias value is
> > not used and the issue doesn't become prominent.
> 
> If tzset doesn't touch _dstbias, the results begin to make sense,
> because it means _dstbias is left at its value determine by previous
> calls, and does not necessarily correspond to the timezone set by the
> call to tzset.  But if that is the case, we should correct this bug by
> examining the value of TZ and assigning to _dstbias the value of
> either -3600 or zero, depending on whether the value of TZ does or
> doesn't specify the "DST" part.  IOW, blindly "correcting" the zero
> value of _dstbias is not right; we should instead go by the DST
> definition of the value in TZ.

I think I see the problem: when TZ is defined in the environment,
tzset updates _daylight, but doesn't touch _dstbias.  So if you start
from a timezone without DST and then switch to a timezone with DST,
_dstbias stays zero, and local time is computed incorrectly.

Therefore, I suggest the patches below.  Could you please try them?

> See above: I think I changed my mind, and we should set _dstbias
> according to the actual value of TZ, and only if TZ is indeed set

The patches below implement this, by using _daylight as the evidence
that TZ defines DST.

diff --git a/src/timefns.c b/src/timefns.c
index 4d296ff..8cf424b 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -189,6 +189,7 @@ emacs_localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
      display-time) are in real danger of missing timezone and DST
      changes.  Calling tzset before each localtime call fixes that.  */
   tzset ();
+  w32_fix_tzset ();
 #endif
   tm = localtime_rz (tz, t, tm);
   if (!tm && errno == ENOMEM)
@@ -306,6 +307,9 @@ tzlookup (Lisp_Object zone, bool settz)
       block_input ();
       emacs_setenv_TZ (zone_string);
       tzset ();
+#ifdef WINDOWSNT
+      w32_fix_tzset ();
+#endif
       timezone_t old_tz = local_tz;
       local_tz = new_tz;
       tzfree (old_tz);
diff --git a/src/w32.c b/src/w32.c
index 5de721a..a98a008 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -10289,6 +10289,30 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname)
 }
 
 
+/* mingw.org's MinGW doesn't declare _dstbias.  MinGW64 defines it as a
+   macro.  */
+#ifndef _dstbias
+__MINGW_IMPORT int _dstbias;
+#endif
+
+/* Fix a bug in MS implementation of 'tzset', to be called immediately
+   after 'tzset'.  */
+void
+w32_fix_tzset (void)
+{
+  char *tz_env = getenv ("TZ");
+
+  /* When TZ is defined in the environment, '_tzset' updates _daylight,
+     but not _dstbias.  Then if we are switching from a timezone without
+     DST to a timezone with DST, 'localtime' and friends will apply zero
+     DST bias, which is incorrect. (When TZ is not defined, '_tzset'
+     does update _dstbias using values obtained from Windows API
+     GetTimeZoneInformation.)  Here we fix that blunder by detecting
+     this situation and forcing _dstbias to be 1 hour.  */
+  if (tz_env && _daylight && !_dstbias)
+    _dstbias = -3600;
+}
+
 /* The Windows CRT functions are "optimized for speed", so they don't
    check for timezone and DST changes if they were last called less
    than 1 minute ago (see http://support.microsoft.com/kb/821231).  So
@@ -10299,6 +10323,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname)
 sys_localtime (const time_t *t)
 {
   tzset ();
+  w32_fix_tzset ();
   return localtime (t);
 }
 
diff --git a/src/w32.h b/src/w32.h
index ae3999f..9d9887e 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -234,6 +234,7 @@ #define FILE_DONT_CLOSE         0x1000
 extern int fchmodat (int, char const *, mode_t, int);
 extern int lchmod (char const *, mode_t);
 extern bool symlinks_supported (const char *);
+extern void w32_fix_tzset (void);
 
 
 /* Return total and free memory info.  */




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 25 May 2025 15:51:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 25 11:51:19 2025
Received: from localhost ([127.0.0.1]:47067 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJDd9-0001hP-3c
	for submit <at> debbugs.gnu.org; Sun, 25 May 2025 11:51:19 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45362)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uJDd6-0001gr-Cb
 for 11281 <at> debbugs.gnu.org; Sun, 25 May 2025 11:51:17 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uJDcz-00022b-05; Sun, 25 May 2025 11:51:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=3Kqcne7wDyFhI/r6acC+G0vh3zYdGAcNVZuwBSIgyLk=; b=BttDYfJfVi/H
 FdCi5CS6R49+Afq6D0l+1FXf6ZnocOZ4CgOPUpRsjKl0Qsp5otq/e1eBtH/4R8BncKg8cS9Z2aY7d
 KCHQyVbyVLfSRb4jGj6kcnEPGpbai7BDRoaAaJsnoDl1gO5H/F1jQmcCMTw8/As9q9j7P6BZ9S59V
 UbsOCuDerluGXOQm9ScEdCVgCQsL1VVVGK83DAgy6OqRY5BO2nAmPLOlfqkuuItlBajnfKPf9tJDB
 4NLt0G+y30i5JJ82eDJWJbqq9xQX70Cqk8c3cA0TZHCbdF597eWjCCife08Sa3w9WQl5tMirCq29b
 2eJnkAfvRLQWnxHO+EenXg==;
Date: Sun, 25 May 2025 18:51:06 +0300
Message-Id: <86h618zo2d.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <857c24wwwo.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Mon, 26 May 2025 00:08:23 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>	<858qmkx5gg.wl--xmue@HIDDEN>	<86iklozvd5.fsf@HIDDEN>
 <857c24wwwo.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 26 May 2025 00:08:23 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> 
> > > > JST-9
> > > > _daylight = 0
> > > > _timezone = -32400
> > > > _tzname[0] = JST
> > > > _dstbias = -3600
> > 
> > Isn't this result strange?  If a timezone has no DST, why is _dstbias
> > not zero?
> 
> I feel it is strange, too.  My understanding is that tzset does not
> touch _dstbias when timezone is specified by TZ environmental variable
> and it is the bug.  However when _daylight is zero, _dstbias value is
> not used and the issue doesn't become prominent.

If tzset doesn't touch _dstbias, the results begin to make sense,
because it means _dstbias is left at its value determine by previous
calls, and does not necessarily correspond to the timezone set by the
call to tzset.  But if that is the case, we should correct this bug by
examining the value of TZ and assigning to _dstbias the value of
either -3600 or zero, depending on whether the value of TZ does or
doesn't specify the "DST" part.  IOW, blindly "correcting" the zero
value of _dstbias is not right; we should instead go by the DST
definition of the value in TZ.

> Please see the
> result of 2nd est5edt, where _dstbias is zero and _daylight is
> non-zero, which causes the issue.  I guess the first -3600 is probably
> initial value because Microsoft says that initial values are for
> "PST8PDT".

I can understand this in your case, since your timezone doesn't
specify DST.  Can you show me what the GetTimeZoneInformation API
returns on your system with your default timezone?

> > Sorry, I don't think I understand: AFAIU, _dstbias can legitimately be
> > zero in timezones that don't support DST.  If that is true, correcting
> > a zero-valued _dstbias to 1 hour will cause problems, no?
> > should also look at the value of _daylight, and only do the _dstbias
> > correction of _daylight is zero (i.e. no DST in this timezone)?  Or
> > what am I missing?
> 
> I agree with you that _dstbias should be zero when _daylight is zero.
> However, as I wrote above, _dstbias should not be used when _daylight
> is zero.  My emacs has set TZ to JST-9 long time and _dstbias has been
> -3600 according to my test.  It has no problem till now.  So I removed
> _daylight value check before posting the patch, but If you mind,
> correcting _dstbias only when _daylight is *NON-ZERO* (not _daylight
> is zero!) should be okay.

See above: I think I changed my mind, and we should set _dstbias
according to the actual value of TZ, and only if TZ is indeed set
(because I think if TZ is not set, MSVCRT gets the correct value from
GetTimeZoneInformation).  Can you try that and see if it improves the
current situation?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 25 May 2025 15:08:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 25 11:08:32 2025
Received: from localhost ([127.0.0.1]:46680 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJCxj-0003Yz-QJ
	for submit <at> debbugs.gnu.org; Sun, 25 May 2025 11:08:32 -0400
Received: from mta-snd-e08.auone-net.jp ([111.86.247.8]:48577)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uJCxf-0003YI-Ot
 for 11281 <at> debbugs.gnu.org; Sun, 25 May 2025 11:08:30 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e08.auone-net.jp with ESMTP
 id <20250525150824042.MXSJ.124732.kzhr.d1.dion.ne.jp@HIDDEN>;
 Mon, 26 May 2025 00:08:24 +0900
Date: Mon, 26 May 2025 00:08:23 +0900
Message-ID: <857c24wwwo.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86iklozvd5.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>	<858qmkx5gg.wl--xmue@HIDDEN>	<86iklozvd5.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=ISO-2022-JP
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748185704; 
 bh=cAG4j/XfT8gejrIj8phr1wSdgsUjMyLwoTiV7IoZGS8=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=WD7Uxb2FbxxKxISWso50SOlMo3hHMf1BCDo3oPkaL4Vpa9tuxDxaxYmYSrNLQalbxQUyIock
 GadpmgcBkkvWGHctC8c/g++f0pMRa7BBzkaNSRxa8AQ8shQnPXWpQG7EViBJEXsqFK9fxm+Jrq
 tcUl0fAMlP7zAqE1Kv7+OQ+y5vghYAMoyYFiWBXbp5nG152WKVpF/dnD527/Coz9pdd4rIWfEv
 K2cznNmP9EAng22CmlxSgQp/kUyRaCuW7kJEC+mxqXAiA8WN6K+aUpWKJZItsLboNNnTAKzSCp
 bZRMs42aFuoYTlNR5w2wVdBypHIkNHaQlmQThKR3pzgOhhdA==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sun, 25 May 2025 22:13:26 +0900,
Eli Zaretskii wrote:
> 
> > Date: Sun, 25 May 2025 21:03:43 +0900
> > From: Kazuhiro Ito <kzhr@HIDDEN>
> > Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> > 
> > > Thanks.  Volunteers are welcome to investigate how MSVCRT works and
> > > why this sometimes causes incorrect results, because I've exhausted my
> > > knowledge of this dark corner.
> > 
> > I've found the fix.
> > I wrote tiny test program.
> > 
> > 
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <time.h>
> > 
> > static void show_globals () {
> >   printf("_daylight = %d\n" , _daylight );
> >   printf("_timezone = %ld\n", _timezone );
> >   printf("_tzname[0] = %s\n", _tzname[0]);
> >   printf("_dstbias = %d\n\n", _dstbias );
> > }
> > 
> > int main(void) {
> >   putenv("TZ=JST-9");
> >   _tzset();
> >   printf("JST-9\n");
> >   show_globals();
> > 
> >   putenv("TZ=est5edt");
> >   _tzset();
> >   printf("est5edt\n");
> >   show_globals();
> > 
> >   putenv("TZ=");
> >   _tzset();
> >   printf("System timezone\n");
> >   show_globals();
> > 
> >   putenv("TZ=est5edt");
> >   _tzset();
> >   printf("est5edt (2nd)\n");
> >   show_globals();
> > 
> >   return 0;
> > }
> > 
> > 
> > Result is here.
> > 
> > > JST-9
> > > _daylight = 0
> > > _timezone = -32400
> > > _tzname[0] = JST
> > > _dstbias = -3600
> 
> Isn't this result strange?  If a timezone has no DST, why is _dstbias
> not zero?

I feel it is strange, too.  My understanding is that tzset does not
touch _dstbias when timezone is specified by TZ environmental variable
and it is the bug.  However when _daylight is zero, _dstbias value is
not used and the issue doesn't become prominent.  Please see the
result of 2nd est5edt, where _dstbias is zero and _daylight is
non-zero, which causes the issue.  I guess the first -3600 is probably
initial value because Microsoft says that initial values are for
"PST8PDT".

> > > est5edt
> > > _daylight = 101
> > > _timezone = 18000
> > > _tzname[0] = est
> > > _dstbias = -3600
> > >
> > > System timezone
> > > _daylight = 0
> > > _timezone = -32400
> > > _tzname[0] = 東京 (標準時)
> > > _dstbias = 0
> > >
> > > est5edt (2nd)
> > > _daylight = 101
> > > _timezone = 18000
> > > _tzname[0] = est
> > > _dstbias = 0

> > But its value is never changed by setting timezone with TZ
> > environmental variable and affects calculation UTC offset of DST.
> > To change _dstbias value to -3600 fixes the issue.
> 
> Sorry, I don't think I understand: AFAIU, _dstbias can legitimately be
> zero in timezones that don't support DST.  If that is true, correcting
> a zero-valued _dstbias to 1 hour will cause problems, no?
> should also look at the value of _daylight, and only do the _dstbias
> correction of _daylight is zero (i.e. no DST in this timezone)?  Or
> what am I missing?

I agree with you that _dstbias should be zero when _daylight is zero.
However, as I wrote above, _dstbias should not be used when _daylight
is zero.  My emacs has set TZ to JST-9 long time and _dstbias has been
-3600 according to my test.  It has no problem till now.  So I removed
_daylight value check before posting the patch, but If you mind,
correcting _dstbias only when _daylight is *NON-ZERO* (not _daylight
is zero!) should be okay.

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 25 May 2025 13:13:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 25 09:13:43 2025
Received: from localhost ([127.0.0.1]:44320 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJBAc-0002UJ-KI
	for submit <at> debbugs.gnu.org; Sun, 25 May 2025 09:13:43 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34676)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uJBAZ-0002Tl-SK
 for 11281 <at> debbugs.gnu.org; Sun, 25 May 2025 09:13:40 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uJBAQ-0001jg-KV; Sun, 25 May 2025 09:13:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=31WknmIJ/LSZ2IKE2w1LXhtxt39VkZkq3L99fHXYsSQ=; b=YLqhwy3XefHXIQSv8Fth
 ae773UBMcAJYLBmp8rgIC7WV4yOwRF4zQn23FdV32JqqBXQ6l/0Uf8vhBSRdiQ4JmF5byDbRrEnQG
 Z46HQ9qZDyL3Qv2mmlEb8/hI3xn/kn5CQEEYw8Vev5RSNWcJiC9Gx67bN2V7scRavLT69/XBWaeYp
 ZdXAJ+9d4ExM/DSX+x1sboUyOsCERs0bVUFhLVdWzhPRopFIV6ocNHUeiFq+UKUUMLaL+PHBVN4HM
 uDOLa/gRf713OJmBBl57UfL6vNxAPHHprUC14xNb8IlNMYhI/R5iWhZWtAz9RWVCD8IuSzhUEV07Q
 WSTpKogAHbtYNw==;
Date: Sun, 25 May 2025 16:13:26 +0300
Message-Id: <86iklozvd5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <858qmkx5gg.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Sun, 25 May 2025 21:03:43 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>
 <858qmkx5gg.wl--xmue@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sun, 25 May 2025 21:03:43 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> 
> > Thanks.  Volunteers are welcome to investigate how MSVCRT works and
> > why this sometimes causes incorrect results, because I've exhausted my
> > knowledge of this dark corner.
> 
> I've found the fix.
> I wrote tiny test program.
> 
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> 
> static void show_globals () {
>   printf("_daylight = %d\n" , _daylight );
>   printf("_timezone = %ld\n", _timezone );
>   printf("_tzname[0] = %s\n", _tzname[0]);
>   printf("_dstbias = %d\n\n", _dstbias );
> }
> 
> int main(void) {
>   putenv("TZ=JST-9");
>   _tzset();
>   printf("JST-9\n");
>   show_globals();
> 
>   putenv("TZ=est5edt");
>   _tzset();
>   printf("est5edt\n");
>   show_globals();
> 
>   putenv("TZ=");
>   _tzset();
>   printf("System timezone\n");
>   show_globals();
> 
>   putenv("TZ=est5edt");
>   _tzset();
>   printf("est5edt (2nd)\n");
>   show_globals();
> 
>   return 0;
> }
> 
> 
> Result is here.
> 
> > JST-9
> > _daylight = 0
> > _timezone = -32400
> > _tzname[0] = JST
> > _dstbias = -3600

Isn't this result strange?  If a timezone has no DST, why is _dstbias
not zero?

> > est5edt
> > _daylight = 101
> > _timezone = 18000
> > _tzname[0] = est
> > _dstbias = -3600
> >
> > System timezone
> > _daylight = 0
> > _timezone = -32400
> > _tzname[0] = 東京 (標準時)
> > _dstbias = 0
> >
> > est5edt (2nd)
> > _daylight = 101
> > _timezone = 18000
> > _tzname[0] = est
> > _dstbias = 0
> 
> When I set timezone to system timezone without DST, _dstbias global
> variable is set to 0.

That's not what I see for JST-9 above.  I compiled the program here,
and I see the same result on my system for JST-9: _daylight is zero,
but _dstbias is -3600.  If I use JST-9JD, I get this:

  JST-9JDT
  _daylight = 74
  _timezone = -32400
  _tzname[0] = JST
  _dstbias = -3600

which is more reasonable.

> But its value is never changed by setting timezone with TZ
> environmental variable and affects calculation UTC offset of DST.
> To change _dstbias value to -3600 fixes the issue.

Sorry, I don't think I understand: AFAIU, _dstbias can legitimately be
zero in timezones that don't support DST.  If that is true, correcting
a zero-valued _dstbias to 1 hour will cause problems, no?  Maybe we
should also look at the value of _daylight, and only do the _dstbias
correction of _daylight is zero (i.e. no DST in this timezone)?  Or
what am I missing?

> Tiny patch is attached.

Thanks.  In any case, we should redirect tzset to a Windows specific
version in w32.c, and do the correction there, instead of in
timefns.c.  In addition, mingw.org's MinGW needs to declare _dstbias
(it doesn't have the declaration in time.h).  I will do all these, but
let's first understand what these changes do and why they fix the
problem, and also how to apply them correctly without adversely
affecting timezones without DST.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 25 May 2025 12:04:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 25 08:04:00 2025
Received: from localhost ([127.0.0.1]:43814 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uJA59-0005Wc-Ug
	for submit <at> debbugs.gnu.org; Sun, 25 May 2025 08:04:00 -0400
Received: from mta-snd-e07.auone-net.jp ([111.86.247.7]:22755)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uJA54-0005W8-KD
 for 11281 <at> debbugs.gnu.org; Sun, 25 May 2025 08:03:57 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e07.auone-net.jp with ESMTP
 id <20250525120350851.MMJW.75697.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Sun, 25 May 2025 21:03:50 +0900
Date: Sun, 25 May 2025 21:03:43 +0900
Message-ID: <858qmkx5gg.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86y0um2zoz.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>	<851psf7mnk.wl--xmue@HIDDEN>	<86sekv4o5h.fsf@HIDDEN>	<85zff3605e.wl--xmue@HIDDEN>	<86h61b4hxg.fsf@HIDDEN>	<85y0un5tug.wl--xmue@HIDDEN>	<86ecwf4e9w.fsf@HIDDEN>	<86cybz4dlf.fsf@HIDDEN>	<85wma6632h.wl--xmue@HIDDEN>	<86y0um2zoz.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: multipart/mixed; boundary="Multipart_Sun_May_25_21:03:43_2025-1"
Content-Transfer-Encoding: 7bit
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748174630; 
 bh=bPkYR1By/7RLqRcqg14G8LlsvjChV+o4IKRFuQ1YGKo=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=XKysZV2QZjvFkkO3wWfGqUU5tz3O1Ja0JcZzzOPKd/hbKwR8zDwMwyG/oYZ+DRg1N9fruJJf
 pUCvGX/AblhoSfQ1tMW7P5kh+43qSraSVizBp4WFKAEAyqL7VW1/J+QiPyPf6gDT5xfghwCCRI
 J7xoRpg4Zj7zukA0CgXc715W+dcemgtw3faLcL7psa33e/078/AKlEhBNk6lktGGwPljxUXJou
 l+I/kP9q3LrP+x+pwgLzdlU8jUhXhxgquN65p3J2dtaXfF1B8RMiAVL6sttJjvDdf2utscpHOq
 yQUVIA5kNbSIPB/ZoaEB5Rc+RByJVGMwMlBv3LTYUf9E2+IQ==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Multipart_Sun_May_25_21:03:43_2025-1
Content-Type: text/plain; charset=ISO-2022-JP

> > ;; After setting timezone without DST in the Windows Control Panel
> > $ TZ= emacs -Q
> > 
> > (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
> >   (setenv "TZ" "JST-9")
> >   (decode-time time "est5edt"))
> > 
> > -> unexpected result
> > 
> > So, following code would fail too.
> > 
> > (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
> >   ;; After setting timezone without DST in the Windows Control Panel
> >   (setenv "TZ" nil)
> >   (setenv "TZ" "JST-9")
> >   (decode-time time "est5edt"))
> > 
> > -> unexpected result
> > 
> > > That is, as long as you tell MSVCRT that
> > > your current timezone doesn't use DST, the conversion is correct.
> > 
> > As I wrote above, this problem occurs after you once call `(setenv
> > "TZ" nil)' under setting that system timezone is non-DST
> > timezone.  If you don't set TZ to nil, conversion would always
> > succeed.
> > 
> > $ TZ=est5edt emacs -Q
> > 
> > (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
> >   (setenv "TZ" "JST-9t")
> >   (decode-time time "est5edt"))
> > 
> > -> expected result
> > 
> > (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
> >   (setenv "TZ" "pst8pdt")
> >   (decode-time time "est5edt"))
> > 
> > -> expected result
> 
> Thanks.  Volunteers are welcome to investigate how MSVCRT works and
> why this sometimes causes incorrect results, because I've exhausted my
> knowledge of this dark corner.

I've found the fix.
I wrote tiny test program.


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static void show_globals () {
  printf("_daylight = %d\n" , _daylight );
  printf("_timezone = %ld\n", _timezone );
  printf("_tzname[0] = %s\n", _tzname[0]);
  printf("_dstbias = %d\n\n", _dstbias );
}

int main(void) {
  putenv("TZ=JST-9");
  _tzset();
  printf("JST-9\n");
  show_globals();

  putenv("TZ=est5edt");
  _tzset();
  printf("est5edt\n");
  show_globals();

  putenv("TZ=");
  _tzset();
  printf("System timezone\n");
  show_globals();

  putenv("TZ=est5edt");
  _tzset();
  printf("est5edt (2nd)\n");
  show_globals();

  return 0;
}


Result is here.

> JST-9
> _daylight = 0
> _timezone = -32400
> _tzname[0] = JST
> _dstbias = -3600
>
> est5edt
> _daylight = 101
> _timezone = 18000
> _tzname[0] = est
> _dstbias = -3600
>
> System timezone
> _daylight = 0
> _timezone = -32400
> _tzname[0] = 東京 (標準時)
> _dstbias = 0
>
> est5edt (2nd)
> _daylight = 101
> _timezone = 18000
> _tzname[0] = est
> _dstbias = 0

When I set timezone to system timezone without DST, _dstbias global
variable is set to 0.  But its value is never changed by setting
timezone with TZ environmental variable and affects calculation UTC
offset of DST.  To change _dstbias value to -3600 fixes the issue.

There may be another issue about timezones where DST shift is not one
hour.  Wikipedia says the Lord Howe Island is so.  However I apologize
for overlooking Emacs on Windows users live there.

Tiny patch is attached.

-- 
Kazuhiro Ito

--Multipart_Sun_May_25_21:03:43_2025-1
Content-Type: text/plain;
 name="0001-Adjust-_dstbias-value-after-tzset-on-Windows.patch"; type=patch; charset=US-ASCII
Content-Disposition: attachment;
 filename="0001-Adjust-_dstbias-value-after-tzset-on-Windows.patch"
Content-Transfer-Encoding: quoted-printable

=46rom 26efb655b49a2c7aa67b287f16fa99d737b1a50a Mon Sep 17 00:00:00 2001
From: Kazuhiro Ito <kzhr@HIDDEN>
Date: Sun, 25 May 2025 20:04:48 +0900
Subject: [PATCH] Adjust _dstbias value after tzset on Windows.

tzset of Windows CRT may set _dstbias to 0, it causes wrong result
of UTC offset calculation for DST timezone specified by timezone
name.  Set its value to -3600, suitable value for US's rule, if
tzset set it to 0. (Bug#11281)

* src/w32.c (sys_localtime): As above.
* src/timefns.c (emacs_localtime_rz, tzlookup): As above.
---
 src/timefns.c | 12 ++++++++++++
 src/w32.c     |  5 +++++
 2 files changed, 17 insertions(+)

diff --git a/src/timefns.c b/src/timefns.c
index 4d296ff8dcd..50de4de5799 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -189,6 +189,11 @@ emacs_localtime_rz (timezone_t tz, time_t const *t, st=
ruct tm *tm)
      display-time) are in real danger of missing timezone and DST
      changes.  Calling tzset before each localtime call fixes that.  */
   tzset ();
+  /* tzset of Windows CRT may set _dstbias to 0, it causes wrong result
+     of UTC offset calculation for DST timezone specified by timezone
+     name. */
+  if (!_dstbias)
+    _dstbias =3D -3600;
 #endif
   tm =3D localtime_rz (tz, t, tm);
   if (!tm && errno =3D=3D ENOMEM)
@@ -306,6 +311,13 @@ tzlookup (Lisp_Object zone, bool settz)
       block_input ();
       emacs_setenv_TZ (zone_string);
       tzset ();
+#ifdef WINDOWSNT
+      /* tzset of Windows CRT may set _dstbias to 0, it causes wrong result
+	 of UTC offset calculation for DST timezone specified by timezone
+	 name. */
+      if (!_dstbias)
+	_dstbias =3D -3600;
+#endif
       timezone_t old_tz =3D local_tz;
       local_tz =3D new_tz;
       tzfree (old_tz);
diff --git a/src/w32.c b/src/w32.c
index 5de721ad71f..c8ffa977829 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -10299,6 +10299,11 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey,=
 Lisp_Object lname)
 sys_localtime (const time_t *t)
 {
   tzset ();
+  /* tzset of Windows CRT may set _dstbias to 0, it causes wrong result
+     of UTC offset calculation for DST timezone specified by timezone
+     name. */
+  if (!_dstbias)
+    _dstbias =3D -3600;
   return localtime (t);
 }
=20
--=20
2.45.1


--Multipart_Sun_May_25_21:03:43_2025-1--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 24 May 2025 08:14:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 24 04:14:17 2025
Received: from localhost ([127.0.0.1]:56491 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uIk1J-0003Ts-B0
	for submit <at> debbugs.gnu.org; Sat, 24 May 2025 04:14:17 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35104)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uIk1G-0003T8-6E
 for 11281 <at> debbugs.gnu.org; Sat, 24 May 2025 04:14:15 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uIk18-0003J3-FB; Sat, 24 May 2025 04:14:06 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=I1rF9izVKVnKXeBADa79pFFMrgEmdfDgKBiV9rQtCWs=; b=nV2Yy2uCVOpR
 Gsg36MYKJvrUMb8qrrLp7XkQvLcWbHGJe5t3woXySGuv36utdjn5dpGhdzTA6oJPgFKlkQZ39q4GX
 3ub1WnTGGbOztCcdUuLqRg5rqpU4pqQGnhv5N516ZYt0Vael4JvjJSvN5GY3KyswqGjKmAdWCrL/y
 BRxwaWm4S9/uOx5z6SiBhDONGZnVqoPuV6Hskgqfdli8njB7EvOtnyr86V+N2S+/DfsYYSKUqZdAM
 N3jYg77uMbCPkTP9MNdzrGH6CPWpjf3AAI5t9ftBTJ6Jnsyn8yb/KvHBfsY+LPsBSveo6nf1BC0Yr
 r0QtCnI9x+4NF4SrhlONIQ==;
Date: Sat, 24 May 2025 11:14:04 +0300
Message-Id: <86y0um2zoz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <85wma6632h.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Sat, 24 May 2025 13:32:54 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN> <86h61b4hxg.fsf@HIDDEN>
 <85y0un5tug.wl--xmue@HIDDEN> <86ecwf4e9w.fsf@HIDDEN>
 <86cybz4dlf.fsf@HIDDEN> <85wma6632h.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sat, 24 May 2025 13:32:54 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org,
> 	stefankangas@HIDDEN
> 
> > 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.
> 
> Yes, but it is true only if you had never called `(setenv "TZ" nil)'.
> Your example yields unexpected result if TZ environmental variable is
> not set at starting emacs (and it is Windows's default).  Probably you
> set TZ environmental variable.

No, TZ is not set on my system.  But my timezone does have DST rules,
so maybe that somehow affects the results.

> ;; After setting timezone without DST in the Windows Control Panel
> $ TZ= emacs -Q
> 
> (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
>   (setenv "TZ" "JST-9")
>   (decode-time time "est5edt"))
> 
> -> unexpected result
> 
> So, following code would fail too.
> 
> (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
>   ;; After setting timezone without DST in the Windows Control Panel
>   (setenv "TZ" nil)
>   (setenv "TZ" "JST-9")
>   (decode-time time "est5edt"))
> 
> -> unexpected result
> 
> > That is, as long as you tell MSVCRT that
> > your current timezone doesn't use DST, the conversion is correct.
> 
> As I wrote above, this problem occurs after you once call `(setenv
> "TZ" nil)' under setting that system timezone is non-DST
> timezone.  If you don't set TZ to nil, conversion would always
> succeed.
> 
> $ TZ=est5edt emacs -Q
> 
> (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
>   (setenv "TZ" "JST-9t")
>   (decode-time time "est5edt"))
> 
> -> expected result
> 
> (let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
>   (setenv "TZ" "pst8pdt")
>   (decode-time time "est5edt"))
> 
> -> expected result

Thanks.  Volunteers are welcome to investigate how MSVCRT works and
why this sometimes causes incorrect results, because I've exhausted my
knowledge of this dark corner.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 24 May 2025 04:33:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 24 00:33:04 2025
Received: from localhost ([127.0.0.1]:54893 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uIgZE-0008Rw-4h
	for submit <at> debbugs.gnu.org; Sat, 24 May 2025 00:33:04 -0400
Received: from mta-snd-e06.auone-net.jp ([111.86.247.6]:8928)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uIgZ8-0008R6-UX
 for 11281 <at> debbugs.gnu.org; Sat, 24 May 2025 00:33:01 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e06.auone-net.jp with ESMTP
 id <20250524043255076.KYCQ.54425.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Sat, 24 May 2025 13:32:55 +0900
Date: Sat, 24 May 2025 13:32:54 +0900
Message-ID: <85wma6632h.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86cybz4dlf.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN> <86h61b4hxg.fsf@HIDDEN>
 <85y0un5tug.wl--xmue@HIDDEN> <86ecwf4e9w.fsf@HIDDEN>
 <86cybz4dlf.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748061175; 
 bh=I97MPtoALS928WIj+n5qCJddf1lx6KfQYICWcGA+hG4=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=RyEzW+Garx4ekRdVv7vTy/mWX6gq9mYTdnDuFePo6e//FAvmVGMLZmV3kRAQ7kRDFOfdXcc1
 4NpeXGLw8D566UasMdpCTPEUfNDLDclCr89vJpk4vyHCm2GDJqZ8n1aUD6jLNXzINZCOZhjQgt
 sGzt1DAbn5ZO8V56NLshCsJLcQNbLVYpYvnvDTIxPWMKE7w6R9/BuCZVZzmVlitcE/ef79Osur
 rsZQp+v1yfQntvdSsx2hgV3SNHrKr7uYgm5rzOE/Z1a7k+X3/ft1By+09njch7zEKf1JBE4r2Q
 3Z81UEvJnbrtC0UCzPtLU8fS9WmDVEE+DNXC+yPt4wxw6bjg==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > > (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.

Yes, but it is true only if you had never called `(setenv "TZ" nil)'.
Your example yields unexpected result if TZ environmental variable is
not set at starting emacs (and it is Windows's default).  Probably you
set TZ environmental variable.

;; After setting timezone without DST in the Windows Control Panel
$ TZ= emacs -Q

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

-> unexpected result

So, following code would fail too.

(let ((time (encode-time '(0 0 12 20 5 2025 nil nil t))))
  ;; After setting timezone without DST in the Windows Control Panel
  (setenv "TZ" nil)
  (setenv "TZ" "JST-9")
  (decode-time time "est5edt"))

-> unexpected result

> That is, as long as you tell MSVCRT that
> your current timezone doesn't use DST, the conversion is correct.

As I wrote above, this problem occurs after you once call `(setenv
"TZ" nil)' under setting that system timezone is non-DST
timezone.  If you don't set TZ to nil, conversion would always
succeed.

$ TZ=est5edt emacs -Q

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

-> expected result

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

-> expected result

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 14:16:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 10:16:26 2025
Received: from localhost ([127.0.0.1]:48691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uITCD-0007ni-JK
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 10:16:26 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42666)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uITCA-0007mh-U6
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 10:16:23 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uITC3-0006IF-Ek; Fri, 23 May 2025 10:16:15 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=bPLuzOGGw/N9DGlFoYPGHkHPbbXdXTBPrF1fiuzcAJc=; b=M8/t+CqEiYeI
 8YVt+zXJ6pr5uI/WPXY31qLkiKH8ShozUgQU+5Q5dTBJnLjhTLKA3lpJ8OZ0LRcRTZWB/X51jtVym
 rPC6bJZYs+tvfOVBsnFkp8AZLZa1IYf5YQml9xLmWzCvO77x7cBTmmZP4IOYIcONc9rGtQunlN5aV
 fgSVS03sD1yAUthCkbbAxe9arkccMqalZb8P09IjPq72a+kP3PHalja7FY5nDnF0qLL/NHjp6ZuTb
 O1xcZ/qSxHDCebqt2FuyCfy1WDUOQbqOsryOXSevGVJuvv0UuMrbLhVGmcbuWUjaU1U7sHaKWDsJ/
 AxrwEyKbsBYgoAX2gtCP1g==;
Date: Fri, 23 May 2025 17:16:12 +0300
Message-Id: <86cybz4dlf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: kzhr@HIDDEN
In-Reply-To: <86ecwf4e9w.fsf@HIDDEN> (message from Eli Zaretskii on Fri, 23
 May 2025 17:01:31 +0300)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN>
 <86h61b4hxg.fsf@HIDDEN> <85y0un5tug.wl--xmue@HIDDEN>
 <86ecwf4e9w.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> Date: Fri, 23 May 2025 17:01:31 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> > (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.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 14:01:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 10:01:48 2025
Received: from localhost ([127.0.0.1]:48557 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uISy4-0006Ut-A8
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 10:01:48 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45258)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uISy1-0006UJ-HC
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 10:01:46 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uISxu-00041i-9o; Fri, 23 May 2025 10:01:38 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ni0bGtNhAHTwCufr8P0nM3q0OP0lLkCIVtuoRTuSBvY=; b=NzGzpz1h+0C6
 vKthl4ehXHNEzLU7JcX/6hJj7kAw9Wesrfd/UCx36fRwKlmsxQ6/2jd4l2tk+iAWr4q2lmwzBdqdh
 H0RrgrgjPMBpDnNPfrFkRYzMRy8y4pz3rxWmiYHyAkwvJPgmWj9qGy4rMvBJM3WxLbCTDYUCVcaNW
 BDbbWQ58OezholjKLxzDJFi3c5V2f54NxtlmYILBTALLLgZbhFN6rp2OCVv1qBXCnE1qFMi9RRPn2
 VTyZ7xWtokBnqQvm2Iuotjynuj+omGp4fQXdXJNDZADbJsLGLbB3hTa8DtmZOvLpJ0s9CB7+YjDoV
 SLjoM+O/+Ym/Hm+NzQfHMQ==;
Date: Fri, 23 May 2025 17:01:31 +0300
Message-Id: <86ecwf4e9w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <85y0un5tug.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Fri, 23 May 2025 22:39:51 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN>
 <86h61b4hxg.fsf@HIDDEN> <85y0un5tug.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 23 May 2025 22:39:51 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org,
> 	stefankangas@HIDDEN
> 
> > 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 13:40:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 09:40:03 2025
Received: from localhost ([127.0.0.1]:47366 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uISd1-0004Rs-6m
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 09:40:03 -0400
Received: from mta-snd-e07.auone-net.jp ([111.86.247.7]:15969)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uIScu-0004Qm-66
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 09:40:00 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e07.auone-net.jp with ESMTP
 id <20250523133952476.KDGS.75697.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Fri, 23 May 2025 22:39:52 +0900
Date: Fri, 23 May 2025 22:39:51 +0900
Message-ID: <85y0un5tug.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86h61b4hxg.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
 <85zff3605e.wl--xmue@HIDDEN> <86h61b4hxg.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1748007592; 
 bh=L0ruYAzXXzGsiYs8CJqgw2WxszkmQLxK2afXmDcvnZE=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=fnOEMSVd5EBgloYsLYTecvdomcZLkUvEsvA6CAk7oRO2bC3YnBDhmo/ETfLWOwYjkeDvUUZB
 rpiILHWxTl7iFVuqzmA7/HYM7WJRVFppn/QmO8DX/BxfqZBiuBUhQFPyVf+QlsNcATO4fqm3ID
 g+AO8gAhTNXX2o5cG20AZK+nal2Dt5boklXghi0WSUIa3oBRLPLQZEELORwqZ1/bpJmGoYzAs2
 ZTETvbBgvVIy8VOEfJBYu5cNtlS3a//GxX30KgH7GtiDlJArgpFxbTqhaZ2noF91+cZtvAliED
 eySsgJnFX/H33Y+ngsTv8xdGpmkfyKHNPTaWceqcjAHkKE3Q==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > > > > 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.
> > > > 
> > > > Thank you for the comment.
> > > > What do you mean by 'such tricks'?  Using traditional timezone name or
> > > > using string as a ZONE pamareter?
> > > 
> > > Neither.  By "tricks" I meant unchecking the DST option in the Windows
> > > Control Panel.
> > 
> > I live in Japan and when I set timezone to Japanese Standard Time in
> > the Windows Control Panel, DST option doesn't appear.  Emacs behaves
> > as if unchecking the DST option.  So, I think many user do the same
> > with unchecking the DST option.
> 
> I was talking about unchecking an option when it does exist and is ON
> by default.

Yes, I know.  I didn't mention in the case of timezone which didn't
have DST, because I didn't expect you suggested not to disable DST.
I live without DST, so I don't know how uncommon to uncheck DST option
is.

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

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 12:43:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 08:43:24 2025
Received: from localhost ([127.0.0.1]:46730 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uIRkB-0007XU-L0
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 08:43:24 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:60970)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uIRk5-0007Wi-Hb
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 08:43:18 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uIRjy-0003OP-5x; Fri, 23 May 2025 08:43:10 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=cb3HAby2hr7AC0mRpXQjGgqOvKbK5rpW14UoDTQHtK4=; b=e+2o1WCjsisc
 UCPbwB/RxihrXyZZf+gJjq0RawttAICIPhCPq21VQkiiBZ3dlgWItaR1YdEqzqsbPPfLpsmwUbQBc
 QNaxYBjC5irRf/9sNe0mUd05nrvfcAQiP8SVSC3xquRm7+CDwN3LzYOdwhoAyJgHOO872QfiGFp6R
 PeBHFVOj5bsmhwjjI1RCY5j0a2qqIrsUnfn2LSO+xqXyKhfwDGws8tHMxW0qrQbvvnV+I8AXDtgNc
 D8KfzxTI8/lkzE3uO4HDIgE/X+RZzzUzBVCFH/R7W1yn4VvkVf0qSOMUMMckep/Yojg8oEzHN2wqb
 6qMgQB+lS1Xies8nk5w7Eg==;
Date: Fri, 23 May 2025 15:42:35 +0300
Message-Id: <86h61b4hxg.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <85zff3605e.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Fri, 23 May 2025 20:23:41 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN>
 <86sekv4o5h.fsf@HIDDEN> <85zff3605e.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 23 May 2025 20:23:41 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org,
> 	stefankangas@HIDDEN
> 
> > > > 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.
> > > 
> > > Thank you for the comment.
> > > What do you mean by 'such tricks'?  Using traditional timezone name or
> > > using string as a ZONE pamareter?
> > 
> > Neither.  By "tricks" I meant unchecking the DST option in the Windows
> > Control Panel.
> 
> I live in Japan and when I set timezone to Japanese Standard Time in
> the Windows Control Panel, DST option doesn't appear.  Emacs behaves
> as if unchecking the DST option.  So, I think many user do the same
> with unchecking the DST option.

I was talking about unchecking an option when it does exist and is ON
by default.

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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 11:23:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 07:23:51 2025
Received: from localhost ([127.0.0.1]:46056 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uIQVD-00066g-27
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 07:23:51 -0400
Received: from mta-snd-e08.auone-net.jp ([111.86.247.8]:4576)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uIQV7-00066P-Nk
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 07:23:48 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e08.auone-net.jp with ESMTP
 id <20250523112342289.KHDX.124732.kzhr.d1.dion.ne.jp@HIDDEN>;
 Fri, 23 May 2025 20:23:42 +0900
Date: Fri, 23 May 2025 20:23:41 +0900
Message-ID: <85zff3605e.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86sekv4o5h.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
 <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN> <86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN> <86sekv4o5h.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1747999422; 
 bh=AThZ/MVoxBVJ2lCeO4S5WHqRbOs5sHRduyREYjimZqE=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=mhAIDeUxszwgT0YcyTA0sP+WAHMVVgKgIsbP5J5zm3vkZWzTdjn3iXpqbLGVmZ0LLtI/5oWw
 NodyJBmeFc/XtA8pKKLXzQ7O3tJ79YZilsXofKJk0efGGTuYhaRqhztLnHrnVJnOTUxLqNKfkO
 nFhN/aPfidNrbwvI7YTYb7lTdMpicZO3uKvyzurYSnhRQVVU9RaWmqn6tfqkgb4p1YRQRWPNNn
 CHWBuHvhrDNMR3nKANEDTxMBv2E1C2Den1MfSr2AOnDT5tS6uw8KhzxXeEfY1pL/Bx9uIz1zNa
 lrHeFcfo0folVs7H04bKz8wBsrJ9O/nXlCCRVHRawEmj0+iA==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > > 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.
> > 
> > Thank you for the comment.
> > What do you mean by 'such tricks'?  Using traditional timezone name or
> > using string as a ZONE pamareter?
> 
> Neither.  By "tricks" I meant unchecking the DST option in the Windows
> Control Panel.

I live in Japan and when I set timezone to Japanese Standard Time in
the Windows Control Panel, DST option doesn't appear.  Emacs behaves
as if unchecking the DST option.  So, I think many user do the same
with unchecking the DST option.

> > If the former, what is proper string for ZONE on Windows?
> In Emacs, the only supported TZ strings are those known to MSVCRT
> time-related functions, which are of the form documented here:

Thank you for the information.

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 10:28:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 06:28:22 2025
Received: from localhost ([127.0.0.1]:45860 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uIPdW-0003Fz-1A
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 06:28:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:56850)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uIPdT-0003Fk-8t
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 06:28:19 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uIPdN-0003hV-9J; Fri, 23 May 2025 06:28:13 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=yaNZRSOddVbjN73asNt9P5fZvCLgo5e+jPoaKZ0CkZo=; b=XhC6kLcf4kTt
 9QVP58+bATq2eG0wInJ/hNTe2bPifkILXdCq7sS0defV0vi8XqzH3SX7u8IBexbZEHb0OQzO51D/3
 bohCGDpxduBYZ8RPl1Z/br4NgxIs0DT25WyiFdg+CUiwrn28+J6EME70P2Fq4kqGNIYe1l52omJBJ
 gh+f/AtTpjPA0VY4mU5bBsiYe8o1yH8AVNiLi6FfbPDpq8zXoXbqaTn/fzjSDr9Eq44mXS2cb2Htp
 0IX7LYcQRS/TyGFM2jpGl35jh+UVTaivrMqwYIC3Fem1+XOsbry749S4NhKeK7s9d2+JA7xBTnZtL
 eP2mptxC+pV0YAkJLSjCSA==;
Date: Fri, 23 May 2025 13:28:10 +0300
Message-Id: <86sekv4o5h.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <851psf7mnk.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Fri, 23 May 2025 17:32:15 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>
 <851psf7mnk.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 23 May 2025 17:32:15 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
> 
> > > (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)
> (snip)
> 
> > 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.
> 
> Thank you for the comment.
> What do you mean by 'such tricks'?  Using traditional timezone name or
> using string as a ZONE pamareter?

Neither.  By "tricks" I meant unchecking the DST option in the Windows
Control Panel.

> If the former, what is proper string for ZONE on Windows?

In Emacs, the only supported TZ strings are those known to MSVCRT
time-related functions, which are of the form documented here:

  https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset?view=msvc-170




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 23 May 2025 08:32:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 23 04:32:29 2025
Received: from localhost ([127.0.0.1]:45242 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uINpM-0003y5-SP
	for submit <at> debbugs.gnu.org; Fri, 23 May 2025 04:32:29 -0400
Received: from mta-snd-e01.auone-net.jp ([111.86.247.1]:54241)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uINpI-0003xh-3d
 for 11281 <at> debbugs.gnu.org; Fri, 23 May 2025 04:32:27 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e01.auone-net.jp with ESMTP
 id <20250523083218859.OENW.20111.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Fri, 23 May 2025 17:32:18 +0900
Date: Fri, 23 May 2025 17:32:15 +0900
Message-ID: <851psf7mnk.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <86plg38li3.fsf@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>	<857c2br068.wl--xmue@HIDDEN>	<86plg38li3.fsf@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1747989140; 
 bh=BCHAh3duQkWNbmsYHie2VdYi3E+Z3jni3m44m+kjKno=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References;
 b=Lwe0X1yB2wu+m0WGVqv9qw6iHjaYsstZhTUyhe98k8Fl/2YHgebqz4c41eEW58lQZd+iJrqA
 3ntF4oULt2mHBH8L6vB+hS/kB4mvCYgrAH5bM52VcuV7Hqy/4/fw0KZRwbJteSbzmlqLLUSsUF
 S8KwWHZqRcnGIV5/LjYvsXlofh54pa41bVjW7Do0IMh7MrWbyXwJx33gxfe6zMLbTbUhJiTdkR
 I5dzQAVVDmOWMem9aQ0ftrs7ltOidW8KIrx5+EmN+I67U/BiFCwq0s/N0i8DJHRdvGvuGlqq/k
 CuLn1zuUhpedvArE9TI2E9zLhOTj1BOKh/X1yuOSc8axXzjQ==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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

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

Thank you for the comment.
What do you mean by 'such tricks'?  Using traditional timezone name or
using string as a ZONE pamareter?  If the former, what is proper
string for ZONE on Windows?

-- 
Kazuhiro Ito




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 20 May 2025 13:23:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 20 09:23:00 2025
Received: from localhost ([127.0.0.1]:57234 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uHMvr-00046L-Gs
	for submit <at> debbugs.gnu.org; Tue, 20 May 2025 09:22:59 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:55220)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uHMvn-00045N-Ct
 for 11281 <at> debbugs.gnu.org; Tue, 20 May 2025 09:22:56 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1uHMvg-0007GJ-C0; Tue, 20 May 2025 09:22:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=Y+djr58nBm74TQtsDQSpdW3wHb51WCJwmPakrblLCc4=; b=esupgwLQSSya
 VtpnXgIK68DG8fTlaQE45Ae9y1ItiTeqjyv7vMgSloW4jXCbgAeCy7wKNVK3Cj9JZR2BMuewDEhtw
 rpEZcgbWNaRjRSbSNwhs3P+4anAlo/cyHKf0+21wqyCfhNuAnWQLFXVki1Q72HEAj7l4grWDVjDhY
 +djUHLZyKYcXYSHmnkVkIzCaW+vjS2Q6leeo+JLY3TztrJFY93g4A7DRfkrYPhlyt6RVwjfGcrdIQ
 GI/PAqxUDm3ASX7l2rh7EP/ii5Rmlm2qLdx4HBwNdzdFdgSH/co2sKCIBEu33t6xDA7kpQeDUXMhX
 XYmO8CvpPLjL3TcZ32uydQ==;
Date: Tue, 20 May 2025 16:22:44 +0300
Message-Id: <86plg38li3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kazuhiro Ito <kzhr@HIDDEN>
In-Reply-To: <857c2br068.wl--xmue@HIDDEN> (message from Kazuhiro Ito on
 Tue, 20 May 2025 20:28:31 +0900)
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
 <857c2br068.wl--xmue@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Tue, 20 May 2025 20:28:31 +0900
> From: Kazuhiro Ito <kzhr@HIDDEN>
> 
> > > 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 20 May 2025 11:28:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 20 07:28:39 2025
Received: from localhost ([127.0.0.1]:55855 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uHL9C-0006fW-FL
	for submit <at> debbugs.gnu.org; Tue, 20 May 2025 07:28:38 -0400
Received: from mta-snd-e03.auone-net.jp ([111.86.247.3]:40609)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kzhr@HIDDEN>)
 id 1uHL99-0006f6-D9
 for 11281 <at> debbugs.gnu.org; Tue, 20 May 2025 07:28:36 -0400
Received: from kzhr.d1.dion.ne.jp by mta-snd-e03.auone-net.jp with ESMTP
 id <20250520112832277.GFVY.25967.kzhr.d1.dion.ne.jp@HIDDEN>; 
 Tue, 20 May 2025 20:28:32 +0900
Date: Tue, 20 May 2025 20:28:31 +0900
Message-ID: <857c2br068.wl--xmue@HIDDEN>
From: Kazuhiro Ito <kzhr@HIDDEN>
To: 11281 <at> debbugs.gnu.org, stefankangas@HIDDEN
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
In-Reply-To: <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>	<87pnibxthy.fsf@HIDDEN>	<CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d1.dion.ne.jp;
 s=default-1; t=1747740512; 
 bh=/lrHGLzsASPHDkOjPtB1q2iy1RauhXTDHw5prgubcak=;
 h=Date:From:To:Subject:In-Reply-To:References;
 b=ZmWduVBSxDcj8qwaV7S8BNSc9iIUndtcVOZtlm2DJGk7jmYwYJE18uJaBkAlKkX8G8bw2L8W
 1+B90xtQW6/mByuBpCK6JdVE6PTIdpmISb6fgVtxZJEw2yeqF6nrXpVRPpe8uMVwhqDvB08zrl
 70+WicrsMRGoWWXiZfdn3VjFoPQI5QOFLKFt+jmdRIGZbQHJ+R/JR6rdiUYcSeREZSROTrYXb7
 OaRJmYbaFv2WSIY6stxJR0ly2J61QjGqw62pKciEm62rVIun27xsRGe4ox6/binkQs/MX3Tja5
 fB9ornrP4r8s0iqYlHJmeQd43PPH61Bf+o2tii2KEqYRojDA==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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

-- 
Kazuhiro Ito





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.
bug unarchived. Request was from Kazuhiro Ito <kzhr@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug archived. Request was from Debbugs Internal Request <help-debbugs@HIDDEN> to internal_control <at> debbugs.gnu.org. Full text available.

Message received at 11281-done <at> debbugs.gnu.org:


Received: (at 11281-done) by debbugs.gnu.org; 7 Aug 2020 11:13:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 07 07:13:06 2020
Received: from localhost ([127.0.0.1]:55913 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1k40J7-0002eY-Tm
	for submit <at> debbugs.gnu.org; Fri, 07 Aug 2020 07:13:06 -0400
Received: from mail-yb1-f173.google.com ([209.85.219.173]:42869)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1k40J5-0002du-Hl
 for 11281-done <at> debbugs.gnu.org; Fri, 07 Aug 2020 07:13:04 -0400
Received: by mail-yb1-f173.google.com with SMTP id a34so808478ybj.9
 for <11281-done <at> debbugs.gnu.org>; Fri, 07 Aug 2020 04:13:03 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:in-reply-to:references:user-agent
 :mime-version:date:message-id:subject:to:cc;
 bh=yzsqiwPuN55LemA0wdOR2bvFNKP/uGO70T9gHhF9nUg=;
 b=lPHs/DIemKGFJEbh2wn73S32wiDzhKr9F3wtUy4o2rjKpqtIih6DwX6Ozx94ZnDa7T
 qHXho/EFj9cK07r6InQkyQyPeDua875Ol8R3oEEoxq0EEeAgRw/1No8L73kmKaHkNzlH
 wrEXySjfvqjAVBBwCTt294q0b1Ja21PHX0wH0rIxmX+4zriTn9IM4qQI2v6PSufxj476
 0b0GeZN1eh4+CXAhZodq+KJsdeq6Vyn89vHQit256/vjr7MVcdObIRp2wFKL1YX3e4no
 JthZRjwm9jY8YKQmfy08ntUqjD7+cNLxxN2Y8LvzkdxYhC0rZkbVXCj0S8f/r8Mu3hlc
 BoDA==
X-Gm-Message-State: AOAM530/VDbPm3lDsy8qpsEynNzFlR+WtbRjzwxu1Pqic4eHgHLwjGqe
 +o378V7UD5SBKMPxXx4BB5380WAtbmtBb8jgjjY=
X-Google-Smtp-Source: ABdhPJwiy+OCvigsWPsyJm4J6Z2WSAW2rRdLnJ8E11bugHHmykwdjM0F4Dkb6UcnOjRtScnZjO5MxeB2fVHd4tU9K+Q=
X-Received: by 2002:a25:9843:: with SMTP id k3mr19762270ybo.466.1596798778013; 
 Fri, 07 Aug 2020 04:12:58 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Fri, 7 Aug 2020 04:12:57 -0700
From: Stefan Kangas <stefan@HIDDEN>
In-Reply-To: <87pnibxthy.fsf@HIDDEN> (Stefan Kangas's message of "Fri, 01
 Nov 2019 20:54:17 +0100")
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 <87pnibxthy.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Date: Fri, 7 Aug 2020 04:12:57 -0700
Message-ID: <CADwFkmmS-kHqbfXVaFY4Xs=RhbTe-bSZ3Du_mBMq9Wgzd0CUiA@HIDDEN>
Subject: Re: bug#11281: DST has not effect on windows XP when system DST
 adjustment is disabled
To: Shuguang Sun <shuguang@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11281-done
Cc: 11281-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Kangas <stefan@HIDDEN> writes:

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

Best regards,
Stefan Kangas




Notification sent to Shuguang Sun <shuguang@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Stefan Kangas <stefan@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 11281 <at> debbugs.gnu.org:


Received: (at 11281) by debbugs.gnu.org; 1 Nov 2019 19:54:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 01 15:54:28 2019
Received: from localhost ([127.0.0.1]:57219 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iQd08-0000O7-99
	for submit <at> debbugs.gnu.org; Fri, 01 Nov 2019 15:54:28 -0400
Received: from host.gofardesign.uk ([208.79.239.190]:37175)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefan@HIDDEN>) id 1iQd06-0000Nq-D0
 for 11281 <at> debbugs.gnu.org; Fri, 01 Nov 2019 15:54:26 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; 
 s=default;
 h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=PU/KclOZ2xfedN2XXBqa4n8SpZSfIgPJ+9uXGiGKKHw=; b=pcSxjMvW4ziBpXGqE7yDF3kD6P
 CSLWkFleLduWlp9BTQnLgvlxqscTtvdNvsuuLWefUdaG5cAkvim5pn5S4FlYMi7/ANhApsnuIDxh6
 o/46SEdgk1q+ewHnXJWlcWkxPih9OzdeCeNEkD3/bFVRGX+6Nr0Ti5/x/9yssLlQDuWc=;
Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:55010
 helo=localhost)
 by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 (Exim 4.92) (envelope-from <stefan@HIDDEN>)
 id 1iQczz-00079P-Jj; Fri, 01 Nov 2019 14:54:20 -0500
From: Stefan Kangas <stefan@HIDDEN>
To: Shuguang Sun <shuguang@HIDDEN>
Subject: Re: DST has not effect on windows XP when system DST adjustment is
 disabled
In-Reply-To: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
 (Shuguang Sun's message of "Fri, 20 Apr 2012 00:35:40 +0800")
References: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
Date: Fri, 01 Nov 2019 20:54:17 +0100
Message-ID: <87pnibxthy.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-OutGoing-Spam-Status: No, score=-1.0
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - host.gofardesign.uk
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - marxist.se
X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id:
 stefan@HIDDEN
X-Authenticated-Sender: host.gofardesign.uk: stefan@HIDDEN
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 11281
Cc: 11281 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Shuguang Sun <shuguang@HIDDEN> writes:

> I'm using GNU Emacs 24.0.95.1 (i386-mingw-nt5.1.2600) of 2012-04-02 on
> MARVIN on WindowsXP SP3. I believe the issue exists in other version
> as well.
>
> In windows,
> 1. If I select the time zone GMP-5 EST (East Standard Time) and  check
> the enable Daylight Saving Time checkbox, the command
> display-time-world in emacs can show the time of New York correctly
> with DST.
> 2. If I select the time zone GMP-5 EST (East Standard Time) and
> UNCHECK the enable Daylight Saving Time checkbox, or if I select a
> time zone without DST, the command display-time-world in emacs can not
> show the time of New York correctly with DST.
> But actually the display-time-world-list for New York is ("EST5EDT"
> "New York"), which (EST5EDT) supposes to enable the Daylight Saving
> Time to show the time.
>
> I try the following code to trace the issue:
> (setq old-tz (getenv "TZ"))
> (setenv "TZ" "EST+5EDT")
> (message (format "%s" (getenv "TZ")))
> (message (format-time-string "%A %d %B %R %Z"))
> (decode-time)
> (setenv "TZ" "EST+5")
> (message (format "%s" (getenv "TZ")))
> (message (format-time-string "%A %d %B %R %Z"))
> (decode-time)
> (setenv "TZ" old-tz)
>
> The output is (Because I select a timezone without DST in windows, the
> time in the outputs is no DST as I described above):
> "EST+5EDT"
> "Thursday 19 April 11:27 EDT"
> (26 27 11 19 4 2012 4 t -18000)
>
> "EST+5"
> "Thursday 19 April 11:27 EST"
> (34 27 11 19 4 2012 4 nil -18000)
>
> (DST is t if daylight saving time is in effect,otherwise nil.from the
> doc of decode-time) From the output of decode-time, it is clear that
> if the TZ is set to "EST+5EDT", the DST is effect. So it is most
> likely the function format-time-string can not catch this information.
> But it is still weird that it DOES has effect if I enable the DST in
> the Windows system.

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?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.
Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs@HIDDEN> to internal_control <at> debbugs.gnu.org. Full text available.
Disconnected #11281 from all other report(s). Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Merged 11281 11807. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Apr 2012 16:45:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 19 12:45:30 2012
Received: from localhost ([127.0.0.1]:42066 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SKuU5-00042s-6C
	for submit <at> debbugs.gnu.org; Thu, 19 Apr 2012 12:45:30 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34405)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <shuguang@HIDDEN>) id 1SKuLL-0003mR-4e
	for submit <at> debbugs.gnu.org; Thu, 19 Apr 2012 12:36:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <shuguang@HIDDEN>) id 1SKuKq-00020s-9o
	for submit <at> debbugs.gnu.org; Thu, 19 Apr 2012 12:36:02 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:54808)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <shuguang@HIDDEN>) id 1SKuKq-00020o-4M
	for submit <at> debbugs.gnu.org; Thu, 19 Apr 2012 12:35:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51352)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <shuguang@HIDDEN>) id 1SKuKk-0006ul-1t
	for bug-gnu-emacs@HIDDEN; Thu, 19 Apr 2012 12:35:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <shuguang@HIDDEN>) id 1SKuKd-0001yv-UL
	for bug-gnu-emacs@HIDDEN; Thu, 19 Apr 2012 12:35:49 -0400
Received: from mail-bk0-f41.google.com ([209.85.214.41]:42649)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <shuguang@HIDDEN>) id 1SKuKd-0001yL-Lm
	for bug-gnu-emacs@HIDDEN; Thu, 19 Apr 2012 12:35:43 -0400
Received: by bkwq16 with SMTP id q16so8208633bkw.0
	for <bug-gnu-emacs@HIDDEN>; Thu, 19 Apr 2012 09:35:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=JOy0YSjiCpzZrsn0A1XCCBqhHVorTFwPrHfX3NhwQOQ=;
	b=z1G89/LTyqF8zH5I+mqHV7+1DnNA3iZYx9DR0i8/YULFtSZHfjnPfAuETqeq/340cK
	nHYa/8GtbWL9Ik2VSK1ll2KQoiNwBjJx68vLi0WWQBkXxkHSjHDWBJqAOU7jZ8J1uCUH
	WDGDCuxGlxSX6QNVK3ZoORs8psoIjM6/8zOk0K2VJDw17YupIfFQz1MEAziCQ7X1ZHF2
	zedku9ROrdk8LfKHsq1UcgkVZzOJpzOB5FX2UwX5Dx72felJakw65hJ4TiA+P0/5P2O2
	//YmU01bUoqM2CLpneDNiTjn+a9GnD/d4jSzFeI54LGBKNdlRzRQp+jFCY2i9y9LsfE8
	+iBQ==
MIME-Version: 1.0
Received: by 10.204.10.79 with SMTP id o15mr871088bko.10.1334853340788; Thu,
	19 Apr 2012 09:35:40 -0700 (PDT)
Received: by 10.205.34.8 with HTTP; Thu, 19 Apr 2012 09:35:40 -0700 (PDT)
Date: Fri, 20 Apr 2012 00:35:40 +0800
Message-ID: <CACspjXd6GzohBiunuxrnPn1cL+sGoFdKdK=JLKMQRzhAQ+CFMA@HIDDEN>
Subject: DST has not effect on windows XP when system DST adjustment is
	disabled
From: Shuguang Sun <shuguang@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.118.235.17
X-Spam-Score: -6.1 (------)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 19 Apr 2012 12:45:26 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.1 (------)

I'm using GNU Emacs 24.0.95.1 (i386-mingw-nt5.1.2600) of 2012-04-02 on
MARVIN on WindowsXP SP3. I believe the issue exists in other version
as well.

In windows,
1. If I select the time zone GMP-5 EST (East Standard Time) and  check
the enable Daylight Saving Time checkbox, the command
display-time-world in emacs can show the time of New York correctly
with DST.
2. If I select the time zone GMP-5 EST (East Standard Time) and
UNCHECK the enable Daylight Saving Time checkbox, or if I select a
time zone without DST, the command display-time-world in emacs can not
show the time of New York correctly with DST.
But actually the display-time-world-list for New York is ("EST5EDT"
"New York"), which (EST5EDT) supposes to enable the Daylight Saving
Time to show the time.

I try the following code to trace the issue:
(setq old-tz (getenv "TZ"))
(setenv "TZ" "EST+5EDT")
(message (format "%s" (getenv "TZ")))
(message (format-time-string "%A %d %B %R %Z"))
(decode-time)
(setenv "TZ" "EST+5")
(message (format "%s" (getenv "TZ")))
(message (format-time-string "%A %d %B %R %Z"))
(decode-time)
(setenv "TZ" old-tz)

The output is (Because I select a timezone without DST in windows, the
time in the outputs is no DST as I described above):
"EST+5EDT"
"Thursday 19 April 11:27 EDT"
(26 27 11 19 4 2012 4 t -18000)

"EST+5"
"Thursday 19 April 11:27 EST"
(34 27 11 19 4 2012 4 nil -18000)

(DST is t if daylight saving time is in effect,otherwise nil.from the
doc of decode-time) From the output of decode-time, it is clear that
if the TZ is set to "EST+5EDT", the DST is effect. So it is most
likely the function format-time-string can not catch this information.
But it is still weird that it DOES has effect if I enable the DST in
the Windows system.




Acknowledgement sent to Shuguang Sun <shuguang@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#11281; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 26 May 2025 15:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.