andrewmcveigh / cljs-time

A clj-time inspired date library for clojurescript.
342 stars 57 forks source link

Minor bug in the parse-number fn in parse.cljs #124

Open dvdreddy opened 6 years ago

dvdreddy commented 6 years ago
(defn parse-number
  ([s limit] (parse-number s 1 limit))
  ([s lower upper]
   (let [[n s] (read-while #(re-find #"\d" %) s)]
     (if (>= (count n) lower)
       [(js/parseInt (apply str (take upper n))) (concat (drop upper n) s)]
       [(js/parseInt (apply str n)) s]))))

The logic is checking if the (>= (count n) lower) instead it should check for (>= (count n) upper) then it should be dropping the elements

Also js/parseInt is dependent on the platform if the radix is not defined and was giving wierd behavior on local rhino platform by considering default radix as 8