(defn mask-date [date]
(let [date (-> date
(clojure.string/replace #"/" "")
(clojure.string/replace #"^(\d{2})(\d{1,})$" "$1/$2")
(clojure.string/replace #"^([\d/]{0,5})(\d{0,})$" "$1/$2")
(.substring 0 10))]
(if (.endsWith date "/")
(.substring date 0 (- (count date) 1))
date)))
This function can be used in a reactive app to mask the date value on the fly while typing.
Top comments (0)