unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Time zone problem in cygwin
@ 2009-02-05 14:47 Ken Brown
  2009-02-05 20:38 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Ken Brown @ 2009-02-05 14:47 UTC (permalink / raw)
  To: emacs-devel

I just built emacs 23 under cygwin from the cvs source of two days ago, 
and the time zone is off by 4 hours; display-time shows 1:30pm when the 
local time is 9:30am.  This happens under both cygwin 1.5 and the (still 
experimental) cygwin 1.7.  The problem does not occur in my build of 
emacs 22.3.  I see in the archives that this problem was reported before:

    http://lists.gnu.org/archive/html/emacs-devel/2008-11/msg00532.html

Eli Zaretskii replied and asked for the value of (format-time-string 
"%Y-%m-%d %T %z").   The OP never responded, but the answer for me is 
the following:  emacs 23 incorrectly reports 2009-02-05 13:35:36 -0100, 
whereas emacs 22.3 correctly gives 2009-02-05 09:36:13 -0500 a few 
seconds later.  One further detail:  emacs 23 gives the right time if I 
set TZ=America/New_York prior to starting emacs; but my understanding is 
that it's not supposed to be necessary to set TZ.

Ken





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
  2009-02-05 14:47 Ken Brown
@ 2009-02-05 20:38 ` Eli Zaretskii
  2009-02-05 22:36   ` Ken Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2009-02-05 20:38 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel

> Date: Thu, 05 Feb 2009 09:47:00 -0500
> From: Ken Brown <kbrown@cornell.edu>
> 
>     http://lists.gnu.org/archive/html/emacs-devel/2008-11/msg00532.html
> 
> Eli Zaretskii replied and asked for the value of (format-time-string 
> "%Y-%m-%d %T %z").   The OP never responded, but the answer for me is 
> the following:  emacs 23 incorrectly reports 2009-02-05 13:35:36 -0100, 
> whereas emacs 22.3 correctly gives 2009-02-05 09:36:13 -0500 a few 
> seconds later.  One further detail:  emacs 23 gives the right time if I 
> set TZ=America/New_York prior to starting emacs; but my understanding is 
> that it's not supposed to be necessary to set TZ.

Unfortunately, I don't have Cygwin installed, so I'm forced to ask
you: can you please step through format-time-string in both Emacs 22.3
and Emacs 23, and see where does the difference come from?

Btw, were both binaries compiled with the same versions of the Cygwin
runtime libraries?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
  2009-02-05 20:38 ` Eli Zaretskii
@ 2009-02-05 22:36   ` Ken Brown
  2009-02-06  6:24     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Ken Brown @ 2009-02-05 22:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2/5/2009 3:38 PM, Eli Zaretskii wrote:
>> Date: Thu, 05 Feb 2009 09:47:00 -0500
>> From: Ken Brown <kbrown@cornell.edu>
>>
>>     http://lists.gnu.org/archive/html/emacs-devel/2008-11/msg00532.html
>>
>> Eli Zaretskii replied and asked for the value of (format-time-string 
>> "%Y-%m-%d %T %z").   The OP never responded, but the answer for me is 
>> the following:  emacs 23 incorrectly reports 2009-02-05 13:35:36 -0100, 
>> whereas emacs 22.3 correctly gives 2009-02-05 09:36:13 -0500 a few 
>> seconds later.  One further detail:  emacs 23 gives the right time if I 
>> set TZ=America/New_York prior to starting emacs; but my understanding is 
>> that it's not supposed to be necessary to set TZ.
> 
> Unfortunately, I don't have Cygwin installed, so I'm forced to ask
> you: can you please step through format-time-string in both Emacs 22.3
> and Emacs 23, and see where does the difference come from?

I have virtually no experience with gdb, but I looked at the gdb 
documentation and made an attempt.  I can't make sense of the result. 
What I did was to look at the C source where format-time-string is 
defined, and I saw the C function synchronize_system_time_locale nearby. 
  This led me to try the following gdb session:

$ gdb /usr/local/bin/emacs
[...]
(gdb) break  synchronize_system_time_locale
Breakpoint 1 at 0x4b51c6: file emacs.c, line 2429.
(gdb) run -Q
Starting program: /usr/local/bin/emacs.exe -Q
[New thread 2500.0x1128]
[New thread 2500.0xc0c]
[New thread 2500.0xddc]
[New thread 2500.0x13a0]
[New thread 2500.0x1414]

[At this point I had emacs evaluate (format-time-string "%Y-%m-%d %T 
%z"), triggering the breakpoint]

Breakpoint 1, synchronize_system_time_locale () at emacs.c:2429
2429      synchronize_locale (LC_TIME, &Vprevious_system_time_locale,

I then repeatedly pressed 's' to step through the program, and I didn't 
see anything interesting, or anything different between emacs 22.3 and 
emacs 23, so finally I just pressed 'c' to continue.  At this point 
emacs displayed the result of the evaluation, and it gave the correct 
time!  I've rechecked this several times, and emacs 23 gives the right 
time when it's run under gdb (with or without a breakpoint), and the 
wrong time otherwise.  Do you have any idea what could be going on?

If there's anything else I should try under gdb, please give me detailed 
instructions.  As you can see, I don't know much about debugging.

> Btw, were both binaries compiled with the same versions of the Cygwin
> runtime libraries?

I rebuilt emacs 22.3 before trying the debugging above, so I do have two 
binaries compiled with the same libraries.  And it remains true that 
emacs 22.3 displays the correct time, even when not run under gdb.

Ken





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
  2009-02-05 22:36   ` Ken Brown
@ 2009-02-06  6:24     ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2009-02-06  6:24 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel

> Date: Thu, 05 Feb 2009 17:36:44 -0500
> From: Ken Brown <kbrown@cornell.edu>
> CC: emacs-devel@gnu.org
> 
> Breakpoint 1, synchronize_system_time_locale () at emacs.c:2429
> 2429      synchronize_locale (LC_TIME, &Vprevious_system_time_locale,
> 
> I then repeatedly pressed 's' to step through the program, and I didn't 
> see anything interesting, or anything different between emacs 22.3 and 
> emacs 23, so finally I just pressed 'c' to continue.  At this point 
> emacs displayed the result of the evaluation, and it gave the correct 
> time!  I've rechecked this several times, and emacs 23 gives the right 
> time when it's run under gdb (with or without a breakpoint), and the 
> wrong time otherwise.  Do you have any idea what could be going on?

Sorry, I don't know enough about newlib (the standard C library used
by Cygwin) to tell.  Could you perhaps describe your observations,
including the one that setting TZ solves the problem even outside GDB,
on the Cygwin mailing list and ask the gurus there for advice or
hints?  A thorough description of how Cygwin handles Windows time
zones would probably also help.

Thank you for working on this.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
@ 2009-02-06 16:29 Angelo Graziosi
  2009-02-06 16:50 ` Ken Brown
  2009-02-06 17:40 ` Ken Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Angelo Graziosi @ 2009-02-06 16:29 UTC (permalink / raw)
  To: kbrown; +Cc: emacs-devel

Ken Brown wrote:
> ...and the time zone is off by 4 hours

Does it make any difference, if you build Emacs with/without this patch:

-----------------
diff -Naur emacs.orig/src/strftime.c emacs/src/strftime.c
--- emacs.orig/src/strftime.c   2007-01-14 04:24:37.000000000 +0100
+++ emacs/src/strftime.c        2008-11-27 09:42:03.109375000 +0100
@@ -54,7 +54,7 @@
  # endif
  #endif
  #if HAVE_TZNAME
-#ifndef USE_CRT_DLL
+#if !defined (USE_CRT_DLL) && !defined (CYGWIN)
  extern char *tzname[];
  #endif
  #endif
-----------------

In my case (I build 'with') the difference is 2 hours:

Emacs says that are 3.22 PM, instead they are 17:22. If Emacs has to
print the Greenwich Time, then it should be 16.22 (but perhaps I haven't
understood how time works...)

Cheers,
    Angelo.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
  2009-02-06 16:29 Time zone problem in cygwin Angelo Graziosi
@ 2009-02-06 16:50 ` Ken Brown
  2009-02-06 17:40 ` Ken Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Ken Brown @ 2009-02-06 16:50 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

On 2/6/2009 11:29 AM, Angelo Graziosi wrote:
> Ken Brown wrote:
>> ...and the time zone is off by 4 hours
> 
> Does it make any difference, if you build Emacs with/without this patch:
> 
> -----------------
> diff -Naur emacs.orig/src/strftime.c emacs/src/strftime.c
> --- emacs.orig/src/strftime.c   2007-01-14 04:24:37.000000000 +0100
> +++ emacs/src/strftime.c        2008-11-27 09:42:03.109375000 +0100
> @@ -54,7 +54,7 @@
>  # endif
>  #endif
>  #if HAVE_TZNAME
> -#ifndef USE_CRT_DLL
> +#if !defined (USE_CRT_DLL) && !defined (CYGWIN)
>  extern char *tzname[];
>  #endif
>  #endif
> -----------------

No, I've tried it both with and without the patch, and the error occurs 
either way.

Ken




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Time zone problem in cygwin
  2009-02-06 16:29 Time zone problem in cygwin Angelo Graziosi
  2009-02-06 16:50 ` Ken Brown
@ 2009-02-06 17:40 ` Ken Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Ken Brown @ 2009-02-06 17:40 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

On 2/6/2009 11:29 AM, Angelo Graziosi wrote:
> Ken Brown wrote:
>> ...and the time zone is off by 4 hours
> 
> Emacs says that are 3.22 PM, instead they are 17:22. If Emacs has to
> print the Greenwich Time, then it should be 16.22 (but perhaps I haven't
> understood how time works...)

So for both of us, emacs thinks that our local time is GMT minus 1 hour.

Ken




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-06 17:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-06 16:29 Time zone problem in cygwin Angelo Graziosi
2009-02-06 16:50 ` Ken Brown
2009-02-06 17:40 ` Ken Brown
  -- strict thread matches above, loose matches on Subject: below --
2009-02-05 14:47 Ken Brown
2009-02-05 20:38 ` Eli Zaretskii
2009-02-05 22:36   ` Ken Brown
2009-02-06  6:24     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).