diff --git a/src/cljs/cljs/reader.cljs b/src/cljs/cljs/reader.cljs index a43245b..4d68d20 100644 --- a/src/cljs/cljs/reader.cljs +++ b/src/cljs/cljs/reader.cljs @@ -468,6 +468,11 @@ nil if the end of stream has been reached") (fn [month leap-year?] (get (if leap-year? dim-leap dim-norm) month)))) +(defn- drop-nanos [num] + (if (> num 999) + 999 + num)) + (def ^:private parse-and-validate-timestamp (let [timestamp #"(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?" check (fn [low n high msg] @@ -491,7 +496,7 @@ nil if the end of stream has been reached") (if-not hours 0 (check 0 h 23 "timestamp hour field must be in range 0..23")) (if-not minutes 0 (check 0 m 59 "timestamp minute field must be in range 0..59")) (if-not seconds 0 (check 0 s (if (= m 59) 60 59) "timestamp second field must be in range 0..60")) - (if-not milliseconds 0 (check 0 ms 999 "timestamp millisecond field must be in range 0..999")) + (if-not milliseconds 0 (drop-nanos (check 0 ms 999999999 "timestamp millisecond field must be in range 0..999999999999"))) offset]))))) (defn parse-timestamp