Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get difference between DateTime instances with clj-time

I am trying to calculate the difference between two DateTime instances using clj-time. I looked through the documentation and found clj-time.core/minus and clj-time.core/minus- but both require an instance of org.joda.time.ReadablePeriod and not one of DateTime. I would prefer to use cli-time, but if no solution exists, what would be the cleanest method of calculating the delta using Joda Time?

Thank you for the help.

like image 365
davenportw15 Avatar asked Feb 05 '15 23:02

davenportw15


1 Answers

I use this snippet very often in my daily work:

(ns project.namespace1
  (:require [clj-time
              [core :as t]] )

(let [start-time (t/now)]
  ... do lots of work ...
  (t/in-millis (t/interval start-time (t/now))))
like image 88
Arthur Ulfeldt Avatar answered Oct 13 '22 00:10

Arthur Ulfeldt