 (def firstcontent (comp first :content))
 (def secondcontent (comp second :content))
 
+(defn olderthan
+  "Is this file older than given time?"
+  [suspect age]
+  (> (- (.getTime (java.util.Date.))
+        (.lastModified suspect))
+     age))
+
+(defn cleanup
+  "Delete datafiles older than 30 minutes"
+  []
+  (let [dir (io/file ".")
+        files (.listFiles dir)
+        datafiles (filter #(re-find #"^weatherdata-.+xml$" (.getName %)) files) ]
+    (map (fn [x]
+           (when
+               (olderthan x 1800000)
+             (.delete x)))
+         datafiles)))
+
 (defn -main
   [& args]
   (let [climap (parse-opts args cli-options)

  ;; An option with a required argument
  [["-l" "--location PLACE" "Location"
    :default (:defaultlocation (config))
;;    :parse-fn #(Integer/parseInt %)
    :validate [#(string? %) "Must be a string"]]
   ;; A non-idempotent option
   ["-m" "--measurement MEASUREMENT" "Measurement"

         (tag= :result) (tag= :MeasurementTimeseries)
         (attr= :gml/id measurement) (tag= :point) (tag= :MeasurementTVP)]
        points (eduction (apply comp path) [ennuste])]
    (cleanup)
    (cond
      (:help cliopts)
      (println (str "-l, --location PLACE [" (:defaultlocation (config)) "]\n-m --measurement [" (:defaultmeasurement (config)) "]\n\nPossible values for measurement are:\n" (clojure.string/join " " (sort measurements))))
