all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>, Stefan Kangas <stefan@marxist.se>
Cc: stepheng+savannah@gildea.com, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 0e56883: Move undocumented time-stamp formats closer to format-time-string
Date: Thu, 10 Oct 2019 00:17:54 -0700	[thread overview]
Message-ID: <7b61e0a3-fbad-0bd2-87b1-dca5c29c19fe@cs.ucla.edu> (raw)
In-Reply-To: <83woddu4yp.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

On 10/9/19 11:52 AM, Eli Zaretskii wrote:
> Do you understand why macOS returns UTC where GMT is expected?

Yes, it's what the low-level gmtime_r function returns in its struct tm. This 
aspect of gmtime_r is not standardized, and some implementations return "GMT", 
some "UTC", and I vaguely recall seeing other abbreviations.

I installed the attached patch, which should fix the problem though I've tested 
it only on GNU/Linux.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Port-time-stamp-test-time-zone-to-macOS.patch --]
[-- Type: text/x-patch; name="0001-Port-time-stamp-test-time-zone-to-macOS.patch", Size: 1906 bytes --]

From a05609991f68de5825b37a9ed6b1e5d2cccbd2ae Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 10 Oct 2019 00:15:24 -0700
Subject: [PATCH] Port time-stamp-test-time-zone to macOS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Stefan Kangas in:
https://lists.gnu.org/r/emacs-devel/2019-10/msg00360.html
* test/lisp/time-stamp-tests.el (time-stamp-test-time-zone):
Don’t assume (format-time-string "%Z" 0 t) returns "GMT".
---
 test/lisp/time-stamp-tests.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index ace5e58e36..37822f6e29 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -298,12 +298,14 @@ time-stamp-test-day-number-in-week
 (ert-deftest time-stamp-test-time-zone ()
   "Test time-stamp formats for time zone."
   (with-time-stamp-test-env
-    ;; implemented and documented since 1995
-    (should (equal (time-stamp-string "%Z" ref-time) "GMT"))
-    ;; documented 1995-2019
-    (should (equal (time-stamp-string "%z" ref-time) "gmt"))
-    ;; implemented since 1997, documented since 2019
-    (should (equal (time-stamp-string "%#Z" ref-time) "gmt"))))
+    (let ((UTC-abbr (format-time-string "%Z" ref-time t))
+	  (utc-abbr (format-time-string "%#Z" ref-time t)))
+      ;; implemented and documented since 1995
+      (should (equal (time-stamp-string "%Z" ref-time) UTC-abbr))
+      ;; documented 1995-2019
+      (should (equal (time-stamp-string "%z" ref-time) utc-abbr))
+      ;; implemented since 1997, documented since 2019
+      (should (equal (time-stamp-string "%#Z" ref-time) utc-abbr)))))
 
 (ert-deftest time-stamp-test-non-date-conversions ()
   "Test time-stamp formats for non-date items."
-- 
2.17.1


  reply	other threads:[~2019-10-10  7:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191001032457.2675.32057@vcs0.savannah.gnu.org>
     [not found] ` <20191001032458.E3A4D207F5@vcs0.savannah.gnu.org>
2019-10-09 12:51   ` [Emacs-diffs] master 0e56883: Move undocumented time-stamp formats closer to format-time-string Stefan Kangas
2019-10-09 13:00     ` Stefan Kangas
2019-10-09 18:52       ` Eli Zaretskii
2019-10-10  7:17         ` Paul Eggert [this message]
2019-10-10 10:56           ` Stefan Kangas
2019-10-09 21:31       ` Stephen Gildea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b61e0a3-fbad-0bd2-87b1-dca5c29c19fe@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=stefan@marxist.se \
    --cc=stepheng+savannah@gildea.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.