Subject: Re: bug#11807: (Windows XP issue?) Re: bug#11807: M-x display-time-world & EDT/DST

From: Eli Zaretskii <[email-masked]>
Date: Fri, 29 Jun 2012 13:31:03 +0300

> From: Jambunathan K <[email-masked]>
> Date: Fri, 29 Jun 2012 14:56:10 +0530
> Cc: [email-masked]
> 
> Andreas Schwab <[email-masked]> writes:
> 
> > Jambunathan K <[email-masked]> writes:
> >
> >>> What about (progn (setenv "TZ" "CET-1CEST") (calendar-dst-find-data))?
> >>
> >> (60 0 "CES" "CES" nil nil 0 0)
> >
> > That's your problem.  You have a faulty timezone implementation.

I don't think the MS-Windows version of tzset supports TZ values such
as CET-1CEST.  The time-zone strings it supports need to be 3-letter,
not 4-letter.  See this thread for more:

  http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg00991.html

Since the original report didn't mention CET-1CEST, the results above
might not be relevant to the original problem at all.

FWIW, times displayed by display-time-world on my XP SP3 box coincide
with what http://www.timeanddate.com/worldclock/city.html?n=179 shows
for the respective cities.  This is with today's trunk.  So maybe your
system's MSVCRT.DLL needs to be updated wrt the timezone information
(see below).

> With my machine re-configured to use a remote timezone (as below)
> 
> ,---- (Windows XP/Cygwin) Control Panel->"Date and Time" 
> | 
> |  (GMT-5:00) Eastern Time (US and Canada) and 
> |  Automatically adjust clock for daylight saving changes turned ON
> | 
> |  I also have my "Internet Time" automatically synchronize with
> |  time.windows.com time server.
> `----

In what build of Emacs was the original problem detected?  What is the
value of 'system-configuration' and 'system-configuration-options' in
that build?  And which Emacs version is that?  You didn't say all that
in your original report, AFAICT.

If the problem is not in the Windows native (MinGW or MSVC) build of
Emacs, then all I write here is irrelevant.

> It is difficult to digest an argument that a widely used enterprise
> system such as Windows XP has an obviously buggy implementation.  It is
> quite possible that Emacs is using the platform APIs in wrong manner.
> 
> What library call (dll library) that Emacs uses to fetch time info?  

If you are using a Cygwin build of Emacs, the information comes from
newlib, and you should ask this question on the Cygwin list; disregard
all I said in that case.

If you are using the native Windows build, then the information comes
from MSVCRT.DLL, the Microsoft C runtime library.  It is known that
_tzset and related time functions in MSVCRT implement only a subset of
possible time-zone names, and they do the time-zone calculations in a
simplistic manner, separately from a much more complete implementation
in the Win32 APIs, such as GetTimeZoneInformation, which is used by
the OS itself for displaying local time.  There's an entry in
etc/PROBLEMS about that, search for "timezone".  In addition,
depending on the system updates installed on your machine, it is
possible that the latest updates for MSVCRT need to be installed to
account for the change in US timezones a few years ago, when they
switched from fixed dates for DST change to rule-based dates.

Volunteers are welcome to write a custom implementation of _tzset that
uses those APIs.