   (fn [[path-key & params]]
     (rr/navigate-to path-key (or (first params) {}))))
 
+;; -- Co-effects -----------------------------------------------------------
+
+(reg-cofx
+ :now
+ (fn [coeffects _]
+   (assoc coeffects :now (js.Date.))))
+
 ;; -- Helpers --------------------------------------------------------------
 
 (defn filter-nil [m]
   "Remove from map all key-value pairs where value is nil"
   (into {} (filter (comp some? val) m)))
+
+(defn insert-creation-date [task now]
+  (if (neg? (:db/id task))
+    (assoc task :task/creation-date now)
+    task))
+
+(defn extend-task [task now]
+  (-> task
+       filter-nil
+       (assoc :task/last-update-date now)
+       (insert-creation-date now)))
 
 ;; -- Handlers --------------------------------------------------------------
 

  [_ _]
  (save-store-debounced!))

(def default-interceptors [(after save-database)])

;; -- Effects ---------------------------------------------------------------



(reg-event-fx
  :commit-task
  [save-database-interceptor
   (inject-cofx :now)]
  (fn [{:keys [now]} [_ task]]
    (let [extended-task (extend-task task now)]
      (if (contains? exteded-task :task/title)
        { :navigate [:back] }
        { :transact [extended-task]
          :navigate [:back] }))))
