   [st]
   (let [ans (js/parseInt st)] (when-not (js/isNaN ans) ans)))
 
-(defn str->int [typ]
+(defn str->int
   "Converts string to integer, for typ (int|date)."
+  [typ]
   (case typ
     "int" parse-int
     "date" (fn [date-string]

                   (/ millis-in-day)
                   floor)))))

(defn int->str [typ &{:keys [digits] :or {digits 1}}]
  "Converts integers to strings, for type (int|date).
   Optional digits parameter = number of digits after decimal, default is 1."
  (let [int-fmt-s (str "%." digits "f")
        d->millis #(* millis-in-day %)
        date->str #(when % (.format (js/moment %) "ll"))]

      "int"  #(format int-fmt-s (float %))
      "date" #(date->str (d->millis %)))))

(defn range->str
  "Converts a range of typ (int|date) to a string."
  [[mn mx] typ]
  (let [[mn mx] [(ceil mn) (floor mx)]
        fmt (int->str typ :digits 0)]
    (if (<= mx mn) (fmt mn)
