summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-07-08 04:51:12 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-07-08 04:51:12 +0200
commit6d28421c0438506da10f5bb257b651c09c285331 (patch)
treebebcbb634b7eb39fc2d5968d1362268f1e62cacf
parentbabd5b8b09b928423e15d827dc1d1abcf70036cc (diff)
downloademacs-6d28421c0438506da10f5bb257b651c09c285331.tar.gz
Get time zones right
-rw-r--r--lisp/calendar/iso8601.el12
-rw-r--r--test/lisp/calendar/iso8601-tests.el8
2 files changed, 13 insertions, 7 deletions
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el
index 512ab4b093d..4c66df1b555 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 20a6f9c9cf2..a8f00e74790 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")