Skip to content

Instantly share code, notes, and snippets.

@lyndsysimon
Created December 1, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyndsysimon/3d782f875da3dedc67caec76ba26cbf2 to your computer and use it in GitHub Desktop.
Save lyndsysimon/3d782f875da3dedc67caec76ba26cbf2 to your computer and use it in GitHub Desktop.
Complex function
(ns user
(:require [clj-time.core :as t]))
(defn- merge-time
[start m]
(apply hash-map (reduce concat (map (fn [x] [x (merge (x m) {:time (/ (t/in-millis (t/interval start (t/now))) 1000)})]) (keys m)))))
(def data {:first {:message "First message"
:success true}
:second {:message "Second message"
:success true}})
(merge-time (t/minus (t/now) (t/millis 150)) data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment