Created
January 26, 2017 13:30
-
-
Save danielef/90653b4341c3f38db147a8172aa5bf74 to your computer and use it in GitHub Desktop.
Clojure Month to Number
This file contains hidden or 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
(defn month-text-to-number [text & [locale]] | |
(let [loc (if locale locale java.util.Locale/ENGLISH) | |
dfmt (java.text.SimpleDateFormat. "MMM" loc) | |
date (.parse dfmt text) | |
cal (doto (java.util.Calendar/getInstance) | |
(.setTime date))] | |
(.get cal java.util.Calendar/MONTH))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment