summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-07-29 13:07:09 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-07-29 13:07:09 +0200
commit3769ea22eb274c2cf69f5c96971d7489dc6e6686 (patch)
treeeb83e06a669306e831120ae0d6c5df11b171c98d
parent1af666c6b4325a28a0facaf6424b69ad64b7b254 (diff)
downloademacs-scratch/iso8601.tar.gz
Add some commentaryscratch/iso8601
-rw-r--r--lisp/calendar/iso8601.el31
-rw-r--r--test/lisp/calendar/iso8601-tests.el16
2 files changed, 34 insertions, 13 deletions
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el
index f44ed3858f6..ab0077ac58d 100644
--- a/lisp/calendar/iso8601.el
+++ b/lisp/calendar/iso8601.el
@@ -21,13 +21,33 @@
;;; Commentary:
-;; For a publicly available version of the standards document, see:
-
+;; ISO8601 times basically look like 1985-04-01T15:23:49... Or so
+;; you'd think. This is what everybody means when they say "ISO8601",
+;; but it's in reality a quite large collection of syntaxes, including
+;; week numbers, ordinal dates, durations and intervals. This package
+;; has functions for parsing them all.
+;;
+;; The interface functions are `iso8601-parse', `iso8601-parse-date',
+;; `iso8601-parse-time', `iso8601-parse-zone',
+;; `iso8601-parse-duration' and `iso8601-parse-interval'. They all
+;; return decoded time objects, except the last one, which returns a
+;; list of three of them.
+;;
+;; (iso8601-parse-interval "P1Y2M10DT2H30M/2008W32T153000-01")
+;; '((0 0 13 24 5 2007 nil nil -3600)
+;; (0 30 15 3 8 2008 nil nil -3600)
+;; (0 30 2 10 2 1 nil nil nil))
+;;
+;;
+;; The standard can be found at:
+;;
;; http://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf
-
+;;
;; The Wikipedia page on the standard is also informative:
-
+;;
;; https://en.wikipedia.org/wiki/ISO_8601
+;;
+;; RFC3339 defines the subset that everybody thinks of as "ISO8601".
;;; Code:
@@ -217,7 +237,8 @@ well as variants like \"2008W32\" (week number) and
:minute (or minute 0)
:second (or second 0)
:zone (and zone
- (iso8601-parse-zone zone))))))))
+ (* 60 (iso8601-parse-zone
+ zone)))))))))
(defun iso8601-parse-zone (string)
"Parse STRING, which should be an ISO 8601 time zone.
diff --git a/test/lisp/calendar/iso8601-tests.el b/test/lisp/calendar/iso8601-tests.el
index 7b1dbfdf495..2959f54b811 100644
--- a/test/lisp/calendar/iso8601-tests.el
+++ b/test/lisp/calendar/iso8601-tests.el
@@ -189,24 +189,24 @@
(ert-deftest standard-test-time-of-day-zone ()
(should (equal (iso8601-parse-time "152746+0100")
- '(46 27 15 nil nil nil nil nil 60)))
+ '(46 27 15 nil nil nil nil nil 3600)))
(should (equal (iso8601-parse-time "15:27:46+0100")
- '(46 27 15 nil nil nil nil nil 60)))
+ '(46 27 15 nil nil nil nil nil 3600)))
(should (equal (iso8601-parse-time "152746+01")
- '(46 27 15 nil nil nil nil nil 60)))
+ '(46 27 15 nil nil nil nil nil 3600)))
(should (equal (iso8601-parse-time "15:27:46+01")
- '(46 27 15 nil nil nil nil nil 60)))
+ '(46 27 15 nil nil nil nil nil 3600)))
(should (equal (iso8601-parse-time "152746-0500")
- '(46 27 15 nil nil nil nil nil -300)))
+ '(46 27 15 nil nil nil nil nil -18000)))
(should (equal (iso8601-parse-time "15:27:46-0500")
- '(46 27 15 nil nil nil nil nil -300)))
+ '(46 27 15 nil nil nil nil nil -18000)))
(should (equal (iso8601-parse-time "152746-05")
- '(46 27 15 nil nil nil nil nil -300)))
+ '(46 27 15 nil nil nil nil nil -18000)))
(should (equal (iso8601-parse-time "15:27:46-05")
- '(46 27 15 nil nil nil nil nil -300))))
+ '(46 27 15 nil nil nil nil nil -18000))))
(ert-deftest standard-test-date-and-time-of-day ()
(should (equal (iso8601-parse "19850412T101530")