From ad97dad583829773dc6fe1359650b71156ad3920 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Wed, 26 Mar 2014 22:01:18 +0100 Subject: [PATCH] timestamps converted to unix timestamps --- src/notehub/handler.clj | 9 ++++++--- src/notehub/storage.clj | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/notehub/handler.clj b/src/notehub/handler.clj index e6becee..09a3a31 100644 --- a/src/notehub/handler.clj +++ b/src/notehub/handler.clj @@ -128,9 +128,12 @@ [:h3.central-element.helvetica statistics] [:table#stats.helvetica.central-element (map - #(when (% stats) - [:tr [:td (str (get-message %) ":")] [:td (% stats)]]) - [:published :edited :publisher :views])])))) + #(when-let [v (% stats)] + [:tr + [:td (str (get-message %) ":")] + [:td (if (or (= % :published) (= % :edited)) + (str (java.util.Date. (Long/parseLong v))) v)]]) + [:published :edited :publisher :views])])))) (GET "/:year/:month/:day/:title/edit" [year month day title] (let [noteID (api/build-key year month day title)] diff --git a/src/notehub/storage.clj b/src/notehub/storage.clj index 29ce073..63de504 100644 --- a/src/notehub/storage.clj +++ b/src/notehub/storage.clj @@ -21,10 +21,10 @@ (defmacro redis [cmd & body] `(car/wcar conn (~(symbol "car" (name cmd)) - ~@body))) + ~@body))) (defn get-current-date [] - (str (java.util.Date.))) + (.getTime (java.util.Date.))) (defn valid-publisher? [pid] (= 1 (redis :hexists :publisher-key pid))) @@ -39,7 +39,7 @@ ; This was uncommented, because the DB isn't ; available on heroku at compile time #_ (when-not (valid-publisher? "NoteHub") - (register-publisher "NoteHub")) + (register-publisher "NoteHub")) (defn revoke-publisher [pid] (redis :hdel :publisher-key pid)) @@ -119,8 +119,8 @@ ; and the rest to chars (map #(char (+ (if (< 9 %) 87 48) %)) hash))) url (first - (remove short-url-exists? - (map hash-to-string hash-stream)))] + (remove short-url-exists? + (map hash-to-string hash-stream)))] ; we create two mappings: key params -> short url and back, ; s.t. we can later easily check whether a short url already exists (redis :hset :short-url url key)