emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/iso8601 6d28421: Get time zones right


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] scratch/iso8601 6d28421: Get time zones right
Date: Sun, 7 Jul 2019 22:51:19 -0400 (EDT)

branch: scratch/iso8601
commit 6d28421c0438506da10f5bb257b651c09c285331
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Get time zones right
---
 lisp/calendar/iso8601.el            | 12 ++++++------
 test/lisp/calendar/iso8601-tests.el |  8 +++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el
index 512ab4b..4c66df1 100644
--- a/lisp/calendar/iso8601.el
+++ b/lisp/calendar/iso8601.el
@@ -174,15 +174,15 @@ well as variants like \"2008W32\" (week number) and
 Return the number of minutes."
   (if (not (iso8601--match iso8601--zone-match string))
       (signal 'wrong-type-argument string)
-    (if (match-string 1 string)
+    (if (match-string 2 string)
         ;; HH:MM-ish.
         (let ((hour (string-to-number (match-string 3 string)))
               (minute (and (match-string 4 string)
-                           (string-to-number (match-string 5 string)))))
-          (+ (* (if (equal (match-string 1 string) "-")
-                    (- hour)
-                  hour)
-                60
+                           (string-to-number (match-string 4 string)))))
+          (* (if (equal (match-string 2 string) "-")
+                 -1
+               1)
+             (+ (* hour 60)
                 (or minute 0))))
       ;; "Z".
       0)))
diff --git a/test/lisp/calendar/iso8601-tests.el 
b/test/lisp/calendar/iso8601-tests.el
index 20a6f9c..a8f00e7 100644
--- a/test/lisp/calendar/iso8601-tests.el
+++ b/test/lisp/calendar/iso8601-tests.el
@@ -66,7 +66,13 @@
 
 (ert-deftest test-iso8601-combined ()
   (should (equal (iso8601-parse "2008-03-02T13:47:30")
-                 '(30 47 13 2 3 2008 nil nil nil))))
+                 '(30 47 13 2 3 2008 nil nil nil)))
+  (should (equal (iso8601-parse "2008-03-02T13:47:30Z")
+                 '(30 47 13 2 3 2008 nil nil 0)))
+  (should (equal (iso8601-parse "2008-03-02T13:47:30+01:00")
+                 '(30 47 13 2 3 2008 nil nil 3600)))
+  (should (equal (iso8601-parse "2008-03-02T13:47:30-01")
+                 '(30 47 13 2 3 2008 nil nil -3600))))
 
 (ert-deftest test-iso8601-duration ()
   (should (equal (iso8601-parse-duration "P3Y6M4DT12H30M5S")



reply via email to

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