Last active
February 21, 2019 14:34
-
-
Save LukasRychtecky/4e2d7aea6f352787ac28e0340cbf3d6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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