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

Previous Next

Package: emacs;

Reported by: Shuguang Sun <shuguang <at> gmail.com>

Date: Thu, 19 Apr 2012 16:46:01 UTC

Severity: minor

Done: Stefan Kangas <stefan <at> marxist.se>

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
Cc: 11281 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: bug#11281: DST has not effect on windows XP when system DST adjustment is disabled
Date: Mon, 26 May 2025 19:05:54 +0300
> Date: Mon, 26 May 2025 23:50:51 +0900
> From: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
> Cc: 11281 <at> debbugs.gnu.org,
> 	stefankangas <at> gmail.com
> 
> > 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!

Thanks, will install soon.

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

I concluded that what we need to ensure is the other way around: if
_daylight is non-zero, _dstbias must also be non-zero.  When _daylight
is zero, the value of _dstbias doesn't matter, because localtyime and
friends don't apply _dstbias in that case.




This bug report was last modified 17 days ago.

Previous Next


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