]> dreyeck.freedombox.rocks Git - topic-maps.git/blobdiff - src/ctm/reader.lisp
Canonicalize DateTime timezone offsets with explicit baseline discrepancies
[topic-maps.git] / src / ctm / reader.lisp
index c8b5a2da7ebbf17a735107979db60f1c987228aa..692065d400b3aa3b47a94411594ac1a8aeb26891 100644 (file)
       (:date
        (consume parser)
        (values (topic-maps.tmdm:canonical-date-lexical-form (token-value token)) (topic-maps.tmdm:date-datatype)))
+      (:datetime
+       (consume parser)
+       (multiple-value-bind (value reason) (topic-maps.tmdm:canonical-datetime-lexical-form (token-value token))
+         (unless value (problem 'ctm-unsupported
+                         (if (eq reason :unsupported-bce-timezone-rollover)
+                             :datetime-bce-timezone-rollover :datetime-leap-second-context)
+                         (token-position token) "DateTime normalization is outside the supported BCE/leap-second calendar context."))
+         (values value (topic-maps.tmdm:datetime-datatype))))
       (:excluded-literal
        (problem 'ctm-unsupported :occurrence-literal-datatype (token-position token)
-                "DateTime and the separate CTM '*' literal are outside this slice."))
+                "The separate CTM '*' literal is outside this slice."))
       (:string
        (consume parser)
        (if (punctuation-p parser #\^)
                         (not (topic-maps.tmdm:date-lexical-p (token-value token))))
                (problem 'ctm-rejection :invalid-date-value (token-position token)
                         "Quoted value is not a valid XSD 1.0 date lexical form."))
+             (when (and (string= datatype (topic-maps.tmdm:datetime-datatype))
+                        (not (topic-maps.tmdm:datetime-lexical-p (token-value token))))
+               (problem 'ctm-rejection :invalid-datetime-value (token-position token)
+                        "Quoted value is not a valid XSD 1.0 dateTime."))
              ;; TMDM 4.4 requires absolute anyURI content; quoted content is
              ;; lexical data, never an IRI reference to resolve against the document.
              (when (and (string= datatype (topic-maps.tmdm:iri-datatype))
            (values (token-value token) (topic-maps.tmdm:string-datatype))))
       ((:iri :qname) (values (literal-iri-reference parser) (topic-maps.tmdm:iri-datatype)))
       (otherwise (problem 'ctm-rejection :expected-occurrence-value (token-position token)
-                          "Expected an integer, decimal, date, quoted string or IRI-form Occurrence value.")))))
+                          "Expected an integer, decimal, date, dateTime, quoted string or IRI-form Occurrence value.")))))
 
 (defun read-identity-tail (parser map topic)
   (let ((start (look parser)))