   (for [[k v] metrics-map]
     { :user            username
       :cloud           cloud
-      :start_timestamp (days-from-now day-number)
-      :end_timestamp   (days-from-now (inc day-number))
+      :start_timestamp (days-ago-at-hour day-number)
+      :end_timestamp   (days-ago-at-hour day-number 10)
       :metric_name     k
       :metric_value    v}))
 

  {:user            username
   :cloud           cloud
   :frequency       "daily"
   :start_timestamp (days-from-now day-number)
   :end_timestamp   (days-from-now (inc day-number))
   :usage           (->> {:ram 47185920 :disk 450.67 :cpu 1250}
                         (map (fn [[k v]] {k {:unit_minutes v}}))
                         (into {}))})

    [com.sixsq.slipstream.ssclj.usage.record-keeper :as rc]
    [com.sixsq.slipstream.ssclj.db.impl :as db]
    [com.sixsq.slipstream.ssclj.db.database-binding :as dbdb]
    [clj-time.core :as time]))

(defn days-ago-at-hour
  ([n h]
   (str (time/minus (time/today-at h 0 0 0) (time/days n))))
  ([n]
   (days-ago-at-hour n 0)))

(defn- daily-usage
  [username cloud day-number metrics-map]
  {:user            username
   :cloud           cloud
   :frequency       "daily"
   :start_timestamp (days-ago-at-hour day-number)
   :end_timestamp   (days-ago-at-hour (inc day-number))
   :usage           (->> metrics-map
                         (map (fn [[k v]] {k {:unit_minutes v}}))
                         (into {}))})
