Subject: 24.2; Bug in function format-time-string when used under Windows

From: Bostjan Vilfan <[email-masked]>
Date: Sat, 16 Mar 2013 10:51:18 +0200

--text follows this line--
This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgement at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from `emacs -Q':

evaluate the form (format-time-string "%H:%M ")

DETAILS:
The behavior of Emacs with regard to daylight savings is covered in
section 31.13 of the manual. Briefly, the two most important variables are
calendar-daylight-savings-starts and calendar-daylight-savings-ends,
which are defined in cal-dst. If these variables are nil (or undefined,
when cal-dst is not loaded), daylight savings is not used; otherwise,
they define the start and end of daylight savings time. The default
value for the two variables corresponds to daylight savings in Cambridge,
Massachusetts.

When the function format-time-string is tested under Linux after calling,
e.g., "emacs -Q" by evaluating the form

    "(format-time-string \"%H:%M\")"

one gets the expected answer, i.e., the current local time since the two
above mentioned variables are undefined.

However, when the same is performed under Windows, Emacs uses daylight
savings with start and end corresponding to Cambridge, Massachusetts, in
spite of the fact that the two previously mentioned variables are undefined.
In my case I evaluated the above form at 9:47 AM local time but received the
output 10:47, presumably because daylight savings time is already in force
in Cambridge, Massachusetts, although not in the Central European Time area.

Yet that is not all. (We are still refering to an installation of Emacs
under Windows.) If one creates a small init.el file with the following
contents:

START OF FILE
(load "cal-dst")

(setq calendar-daylight-savings-starts '(calendar-nth-named-day -1 0 3 year))
;(setq calendar-daylight-savings-starts nil)
(setq calendar-daylight-savings-ends '(calendar-nth-named-day -1 0 10 year))
;(setq calendar-daylight-savings-ends nil)
(setq calendar-daylight-time-offset 60)
(setq calendar-daylight-savings-starts-time 180)
(setq calendar-daylight-savings-ends-time 180)
END OF FILE

and invokes emacs with "runemacs --no-splash --no-site-file" (in that
case the init.el will be executed), after which one evaluates the same
form as before, one still gets the Cambridge, Massachusetts version of
daylight savings. In other words, the two above mentioned variables have
no effect.

In GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601)
 of 2012-08-29 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --with-gcc (4.6) --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Info

Minor modes in effect:
  server-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down-mouse-1> <mouse-1> <backspace> <return> <help-echo>
<help-echo> <help-echo> <help-echo> <down-mouse-1>
<mouse-1> <down-mouse-1> <mouse-1> SPC <kp-delete>
<down-mouse-1> <mouse-1> <backspace> <return> <down-mouse-1>
<mouse-1> <kp-delete> SPC <down-mouse-1> <mouse-movement>
<mouse-1> SPC <kp-delete> <help-echo> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<help-echo> <help-echo> <help-echo> <down-mouse-1>
<mouse-1> SPC ( <backspace> <backspace> <down-mouse-1>
<mouse-1> ( W r SPC <backspace> <backspace> e SPC a
r e SPC s t i l l SPC r e f e r i n g SPC t o SPC a
n SPC i n s t a l l a t i o n SPC o f SPC E m a c s
<return> <down-mouse-1> <mouse-1> <kp-delete> SPC <down-mouse-1>
<mouse-1> <return> <up> u n d e r SPC W i n d o w s
. ) SPC <kp-delete> <help-echo> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<help-echo> <tool-bar> <save-buffer> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<tool-bar> <make-frame> <switch-frame> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<help-echo> <help-echo> <menu-bar> <help-menu> <emacs-manual>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <help-echo> <down-mouse-1> <mouse-movement>
<mouse-1> C-s b u g C-s <help-echo> <down-mouse-1>
<mouse-2> <help-echo> <down-mouse-1> <mouse-2> <help-echo>
M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
Saving file m:/orgmode/notes.org...
Wrote m:/orgmode/notes.org
org-agenda-error: Command not allowed in this line
create calendar tool bar item
GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601) of 2012-08-29 on MARVIN
Connection file "c:/Users/Bostjan/Documents/.emacs.d/server/server" deleted
Server mode enabled
Saving file c:/Users/Bostjan/Documents/.emacs.d/daylight-savings-message.txt...
Wrote c:/Users/Bostjan/Documents/.emacs.d/daylight-savings-message.txt
Mark saved where search started

Load-path shadows:
c:/Program Files (x86)/GNU/Emacs/org-7.9.2/contrib/lisp/htmlize hides
c:/PROGRAM FILES (X86)/GNU/EMACS/EMACS24.2M/site-lisp/htmlize

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
misearch multi-isearch info cus-start cus-load org-colview htmlize-view
w32-winprint htmlize cl holidays hol-loaddefs diary-lib diary-loaddefs
cal-iso mule-util cal-move org-wl org-w3m org-vm org-rmail org-mhe
org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks org-agenda org-info org-gnus gnus-util org-docview
org-bibtex bibtex org-bbdb org byte-opt bytecomp byte-compile cconv
macroexp advice help-fns advice-preload ob-tangle ob-ref ob-lob ob-table
org-footnote org-src ob-comint ob-keys org-pcomplete pcomplete comint
ansi-color ring org-list org-faces org-entities noutline outline
easy-mmode org-version ob-emacs-lisp ob org-compat org-macs ob-eval
format-spec find-func warnings server org-install cal-dst regexp-opt
cal-menu easymenu calendar cal-loaddefs paren delsel time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp
w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process multi-tty emacs)