From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#22302: 25.1.50; time-stamp ignores time-stamp-time-zone Date: Tue, 12 Jan 2016 09:14:49 -0800 Organization: UCLA Computer Science Department Message-ID: <56953489.20700@cs.ucla.edu> References: <3tziwb4dgz.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000100080306070301040807" X-Trace: ger.gmane.org 1452618931 1763 80.91.229.3 (12 Jan 2016 17:15:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Jan 2016 17:15:31 +0000 (UTC) Cc: 22302-done@debbugs.gnu.org, Harald Hanche-Olsen To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 12 18:15:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aJ2XM-0000K5-R2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Jan 2016 18:15:17 +0100 Original-Received: from localhost ([::1]:33310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2XM-0005Xs-38 for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Jan 2016 12:15:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2XD-0005Vs-LU for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2016 12:15:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJ2X8-0002GY-PM for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2016 12:15:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2X8-0002GK-M2 for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2016 12:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aJ2X8-0005VI-IL for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2016 12:15:02 -0500 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Jan 2016 17:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 22302 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 22302@debbugs.gnu.org, eggert@cs.ucla.edu, hanche@math.ntnu.no Original-Received: via spool by 22302-done@debbugs.gnu.org id=D22302.145261890021128 (code D ref 22302); Tue, 12 Jan 2016 17:15:02 +0000 Original-Received: (at 22302-done) by debbugs.gnu.org; 12 Jan 2016 17:15:00 +0000 Original-Received: from localhost ([127.0.0.1]:47489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJ2X6-0005Uh-A9 for submit@debbugs.gnu.org; Tue, 12 Jan 2016 12:15:00 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:42579) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJ2X3-0005UU-Ll for 22302-done@debbugs.gnu.org; Tue, 12 Jan 2016 12:14:58 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 27D5B160819; Tue, 12 Jan 2016 09:14:51 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id qPuUNv0TGUVb; Tue, 12 Jan 2016 09:14:50 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EA8541605E4; Tue, 12 Jan 2016 09:14:49 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wWJyKDvRBgv6; Tue, 12 Jan 2016 09:14:49 -0800 (PST) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CD7E41601E7; Tue, 12 Jan 2016 09:14:49 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 In-Reply-To: <3tziwb4dgz.fsf@fencepost.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:111554 Archived-At: This is a multi-part message in MIME format. --------------000100080306070301040807 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 01/11/2016 08:40 PM, Glenn Morris wrote: > Harald Hanche-Olsen wrote: > >> Run emacs -Q and insert this text: >> Time-stamp: <> >> >> Then do: >> M-: (require 'time-stamp) RET >> M-x set-variable RET time-stamp-time-zone RET "UTC" RET >> M-x time-stamp >> >> Expected result: A UTC time stamp is inserted. >> Actual result: A time stamp in the local time zone is inserted. > This is due to af32fa956. Paul, could you have a look please? Thanks for reporting this. I fixed the bug by installing the attached patch to emacs-25. By the way, the value "UTC" is not portable to non-GNU systems, and POSIX says that in theory it could cause Emacs to crash. The value should be "UTC0" or (in Emacs 25) t. I see that some of Emacs's own source files have this issue, and plan to look into that. --------------000100080306070301040807 Content-Type: text/x-patch; name="0001-Fix-time-stamp-time-zone-bugs-introduced-in-July.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-time-stamp-time-zone-bugs-introduced-in-July.patch" >From 92f27b6928b99b75630cda663c4a726c0b8ec0bf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 12 Jan 2016 09:09:27 -0800 Subject: [PATCH] Fix time-stamp-time-zone bugs introduced in July This fixes a bug introduced when the July changes to format-time-string installed, as the changes were not correctly handled in this module (Bug#22302). Also, document time stamp time zones. * lisp/time-stamp.el (time-stamp-time-zone): Document values better. (time-stamp--format): New private function. (time-stamp-string, time-stamp-string-preprocess) (time-stamp-do-number): Use it. * doc/emacs/files.texi (Time Stamps): Mention time zones. * doc/misc/autotype.texi (Timestamps): Document time-stamp-time-zone. --- doc/emacs/files.texi | 7 ++++--- doc/misc/autotype.texi | 8 +++++--- lisp/time-stamp.el | 48 ++++++++++++++++++++++++++---------------------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index bfa55d3..3d5562d 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -881,9 +881,10 @@ Time Stamps @code{before-save-hook} (@pxref{Hooks}). When you save the file, this function then automatically updates the time stamp with the current date and time. You can also use the command @kbd{M-x time-stamp} to -update the time stamp manually. For other customizations, see the -Custom group @code{time-stamp}. Note that the time stamp is formatted -according to your locale setting (@pxref{Environment}). +update the time stamp manually. By default the time stamp is +formatted according to your locale setting (@pxref{Environment}) and +time zone (@pxref{Time of Day,,, elisp, The Emacs Lisp Reference +Manual}). For customizations, see the Custom group @code{time-stamp}. @node Reverting @section Reverting a Buffer diff --git a/doc/misc/autotype.texi b/doc/misc/autotype.texi index 839782a..6bdbd34 100644 --- a/doc/misc/autotype.texi +++ b/doc/misc/autotype.texi @@ -531,15 +531,17 @@ Timestamps customization buffer. @vindex time-stamp-active +@findex time-stamp-toggle-active @vindex time-stamp-format -@vindex time-stamp-start +@vindex time-stamp-time-zone The time stamp is updated only if the customizable variable @code{time-stamp-active} is on, which it is by default; the command @code{time-stamp-toggle-active} can be used to toggle it. The format of -the time stamp is set by the customizable variable -@code{time-stamp-format}. +the time stamp is set by the customizable variables +@code{time-stamp-format} and @code{time-stamp-time-zone}. @vindex time-stamp-line-limit +@vindex time-stamp-start @vindex time-stamp-end @vindex time-stamp-count @vindex time-stamp-inserts-lines diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el index 46c993e..dffd590 100644 --- a/lisp/time-stamp.el +++ b/lisp/time-stamp.el @@ -121,9 +121,12 @@ time-stamp-old-format-warn :group 'time-stamp) (defcustom time-stamp-time-zone nil - "If non-nil, a string naming the timezone to be used by \\[time-stamp]. -Format is the same as that used by the environment variable TZ on your system." - :type '(choice (const nil) string) + "The time zone to be used by \\[time-stamp]. +Its format is that of the ZONE argument of the `format-time-string' function," + :type '(choice (const :tag "Emacs local time" nil) + (const :tag "Universal Time" t) + (const :tag "system wall clock time" wall) + (string :tag "TZ environment variable value")) :group 'time-stamp :version "20.1") ;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p) @@ -412,6 +415,8 @@ time-stamp-toggle-active (> (prefix-numeric-value arg) 0))) (message "time-stamp is now %s." (if time-stamp-active "active" "off"))) +(defun time-stamp--format (format time) + (format-time-string format time time-stamp-time-zone)) (defun time-stamp-string (&optional ts-format) "Generate the new string to be inserted by \\[time-stamp]. @@ -420,8 +425,7 @@ time-stamp-string (or ts-format (setq ts-format time-stamp-format)) (if (stringp ts-format) - (format-time-string (time-stamp-string-preprocess ts-format) - nil time-stamp-time-zone) + (time-stamp--format (time-stamp-string-preprocess ts-format) nil) ;; handle version 1 compatibility (cond ((or (eq time-stamp-old-format-warn 'error) (and (eq time-stamp-old-format-warn 'ask) @@ -515,32 +519,32 @@ time-stamp-string-preprocess "%%") ((eq cur-char ?a) ;day of week (if change-case - (format-time-string "%#a" time) + (time-stamp--format "%#a" time) (or alt-form (not (string-equal field-width "")) (time-stamp-conv-warn "%a" "%:a")) (if (and alt-form (not (string-equal field-width ""))) "" ;discourage "%:3a" - (format-time-string "%A" time)))) + (time-stamp--format "%A" time)))) ((eq cur-char ?A) (if alt-form - (format-time-string "%A" time) + (time-stamp--format "%A" time) (or change-case (not (string-equal field-width "")) (time-stamp-conv-warn "%A" "%#A")) - (format-time-string "%#A" time))) + (time-stamp--format "%#A" time))) ((eq cur-char ?b) ;month name (if change-case - (format-time-string "%#b" time) + (time-stamp--format "%#b" time) (or alt-form (not (string-equal field-width "")) (time-stamp-conv-warn "%b" "%:b")) (if (and alt-form (not (string-equal field-width ""))) "" ;discourage "%:3b" - (format-time-string "%B" time)))) + (time-stamp--format "%B" time)))) ((eq cur-char ?B) (if alt-form - (format-time-string "%B" time) + (time-stamp--format "%B" time) (or change-case (not (string-equal field-width "")) (time-stamp-conv-warn "%B" "%#B")) - (format-time-string "%#B" time))) + (time-stamp--format "%#B" time))) ((eq cur-char ?d) ;day of month, 1-31 (time-stamp-do-number cur-char alt-form field-width time)) ((eq cur-char ?H) ;hour, 0-23 @@ -554,27 +558,27 @@ time-stamp-string-preprocess ((eq cur-char ?p) ;am or pm (or change-case (time-stamp-conv-warn "%p" "%#p")) - (format-time-string "%#p" time)) + (time-stamp--format "%#p" time)) ((eq cur-char ?P) ;AM or PM - (format-time-string "%p" time)) + (time-stamp--format "%p" time)) ((eq cur-char ?S) ;seconds, 00-60 (time-stamp-do-number cur-char alt-form field-width time)) ((eq cur-char ?w) ;weekday number, Sunday is 0 - (format-time-string "%w" time)) + (time-stamp--format "%w" time)) ((eq cur-char ?y) ;year (or alt-form (not (string-equal field-width "")) (time-stamp-conv-warn "%y" "%:y")) - (string-to-number (format-time-string "%Y" time))) + (string-to-number (time-stamp--format "%Y" time))) ((eq cur-char ?Y) ;4-digit year, new style - (string-to-number (format-time-string "%Y" time))) + (string-to-number (time-stamp--format "%Y" time))) ((eq cur-char ?z) ;time zone lower case (if change-case "" ;discourage %z variations - (format-time-string "%#Z" time))) + (time-stamp--format "%#Z" time))) ((eq cur-char ?Z) (if change-case - (format-time-string "%#Z" time) - (format-time-string "%Z" time))) + (time-stamp--format "%#Z" time) + (time-stamp--format "%Z" time))) ((eq cur-char ?f) ;buffer-file-name, base name only (if buffer-file-name (file-name-nondirectory buffer-file-name) @@ -634,7 +638,7 @@ time-stamp-do-number (format "%%:%c" format-char))) (if (and alt-form (not (string-equal field-width ""))) "" ;discourage "%:2d" and the like - (string-to-number (format-time-string format-string time))))) + (string-to-number (time-stamp--format format-string time))))) (defvar time-stamp-conversion-warn t "Warn about soon-to-be-unsupported forms in `time-stamp-format'. -- 2.5.0 --------------000100080306070301040807--