One difficult issue when normalizing and cleaning up data is dealing with time. People enter dates and times in a bewildering variety of formats, some of them ambiguous. But we have to do our best to interpret them and normalize them into a standard format.
In this recipe, we'll define a function that attempts to parse a date into a standard string format. We'll use the Clojure clj-time
library, which is a wrapper around the Joda Java library (http://joda-time.sourceforge.net/).
First we need to declare our dependencies in the Leiningen project.clj
file as shown in the following code snippet:
:dependencies [[org.clojure/clojure "1.4.0"] [clj-time "0.4.4"]]
And, we need to load those into the our script or REPL. This can be done using the following code snippet:
(use '[clj-time.core :exclude (extend)] '[clj-time.format])