Skip to content

Instantly share code, notes, and snippets.

@LukasRychtecky
Last active February 21, 2019 14:34
Show Gist options
  • Save LukasRychtecky/4e2d7aea6f352787ac28e0340cbf3d6e to your computer and use it in GitHub Desktop.
Save LukasRychtecky/4e2d7aea6f352787ac28e0340cbf3d6e to your computer and use it in GitHub Desktop.
(ns datetime
(:require [cljs-time.format :refer [formatter unparse parse formatters]]
[clojure.string :as string]))
(def human-date-fmt (formatter "dd. MM. yyyy"))
(defn fmt
"Formats a given `datetime` by a given `fmt` or a default formatter."
([datetime fmt]
(when-not (string/blank? datetime)
(unparse fmt (parse datetime))))
([datetime]
(fmt datetime human-date-fmt)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment