Skip to content

Instantly share code, notes, and snippets.

@l1x
Created February 5, 2014 04:59
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 l1x/8817664 to your computer and use it in GitHub Desktop.
Save l1x/8817664 to your computer and use it in GitHub Desktop.
(defn epoch
"Returns (System/currentTimeMillis)/1000"
[]
(int (/ (System/currentTimeMillis) 1000)))
(defn epoch-min
"Returns the epoch-min, to any epoch input
epoch min is the the last minute's epoch value
1390086540 1390086600 1390086660"
[epoch]
(- epoch (mod epoch 60)))
(defn last-datapoints
"Return a vector with n elements starting with epoch"
[epoch n]
(let [e (epoch-min epoch)]
(vec (map #(- e (* % 60)) (range n)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment