emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master 085c7f6 2/2: Test format-time-string with zone


From: Eli Zaretskii
Subject: Re: [Emacs-diffs] master 085c7f6 2/2: Test format-time-string with zone arg
Date: Mon, 01 May 2017 10:43:10 +0300

> From: Paul Eggert <address@hidden>
> Date: Sun, 30 Apr 2017 13:49:53 -0700
> 
> Ken Brown wrote:
> > This test fails on Cygwin.
> >
> > (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0)
> >             "NZST-12NZDT,M9.5.0,M4.1.0/3")
> >
> > evaluates to "1970-01-01 12:00:00 +1200 (NZST)".  Can you give me some 
> > guidance
> > as to how to track this down?  I know nothing about how time zones work.
> 
> What does this shell command do?
> 
> TZ='NZST-12NZDT,M9.5.0,M4.1.0/3' date address@hidden +'%Y-%m-%d %H:%M:%S %z 
> (%Z)'
> 
> On a working system with GNU 'date', it should output this:
> 
> 1970-01-01 13:00:00 +1300 (NZDT)
> 
> If it outputs "1970-01-01 12:00:00 +1200 (NZST)" on Cygwin, it's a bug in 
> Cygwin 
> not in Emacs per se. If so, perhaps we should just skip the test on Cygwin 
> (you 
> might file a Cygwin bug report). If not, I'll have some other questions to 
> ask.

I've found 2 issues with this test in the MinGW build on MS-Windows.
I would like to propose the following changes.  Paul, is it okay to
commit this?

diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 44595be..80af441 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -144,12 +144,16 @@ transpose-test-get-byte-positions
            (format-time-string "%Y-%m-%d %H:%M:%S %z" '(0 0 0 0) t)
            "1970-01-01 00:00:00 +0000"))
   (should (string-equal
-           (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0) "PST8")
-           "1969-12-31 16:00:00 -0800 (PST)"))
-  (should (string-equal
-           (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0)
-                               "NZST-12NZDT,M9.5.0,M4.1.0/3")
-           "1970-01-01 13:00:00 +1300 (NZDT)")))
+           ;; Use local date of Jan 2, 1970, as MS-Windows produces an empty
+           ;; numerical time-zone from %z for times before the epoch.
+           (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(1 20864 0 0) 
"PST8")
+           "1970-01-01 16:00:00 -0800 (PST)"))
+  ;; MS-Windows doesn't support the full  Posix format of TZ values.
+  (or (eq system-type 'windows-nt)
+      (should (string-equal
+               (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0)
+                                   "NZST-12NZDT,M9.5.0,M4.1.0/3")
+               "1970-01-01 13:00:00 +1300 (NZDT)"))))
 
 ;;; This should not dump core.
 (ert-deftest format-time-string-with-outlandish-zone ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]