Back
>= (clj)
(source)function
(>= _x)
(>= x y)
(>= x y & more)
Same as clojure.core/>=, but works on dates, rather than numbers
Examples
tick
(ns tick.api-test
(:require
[clojure.test
:refer [deftest is testing run-tests]
:refer-macros [deftest is testing run-tests]]
[tick.core :as t]
[tick.locale-en-us]
[tick.protocols :as p]
[cljc.java-time.clock]
[cljc.java-time.instant]
[cljc.java-time.day-of-week]
[cljc.java-time.month]
[cljc.java-time.year]
#?@(:cljs [[java.time :refer [Instant]]]))
#?(:clj
(:import [java.time Instant])))
(deftest comparison-test
(let [point (t/truncate (t/instant) :millis)
later (t/>> point (t/new-duration 1 :millis))]
(testing "shifting inst"
(let [i (t/inst)]
(is (= i (-> i
(t/>> (t/new-duration 10 :seconds))
(t/<< (t/new-duration 10 :seconds)))))))
(testing "max-min"
(is (= later (t/max point later point later)))
(is (= point (t/min point later point later))))
(testing "max-min key"
(is (= {:foo later} (t/max-key :foo {:foo point} {:foo later} {:foo point} {:foo later})))
(is (= {:foo point} (t/min-key :foo {:foo point} {:foo later} {:foo point} {:foo later}))))
(testing "comparables not="
(doseq [point (point-in-time-comparable point)]
(testing "comparables ="
(is (apply t/= point (point-in-time-comparable point)))
(is (apply t/>= point (point-in-time-comparable point))))
(is (apply t/<= point (point-in-time-comparable later))))
(doseq [later (point-in-time-comparable later)]
(is (apply t/>= later (point-in-time-comparable point))))
(doseq [point (point-in-time-comparable point)
later (point-in-time-comparable later)]
(is (t/<= point later))
(is (t/< point later))
(is (t/>= later point))
(is (t/> later point)))))
(testing "Instants and ZonedDateTimes should be equals if represents the same point in time"
(is (t/=
(t/instant (t/clock (t/instant "2017-10-31T16:00:00Z")))
(t/zoned-date-time "2017-10-31T16:00:00Z[UTC]"))))
(is
(t/<
(t/now)
(t/>> (t/now) (t/new-duration 10 :seconds))
(t/>> (t/now) (t/new-duration 20 :seconds))))
(is
(t/>
(t/>> (t/now) (t/new-duration 20 :seconds))
(t/>> (t/now) (t/new-duration 10 :seconds))
(t/now)))
(is (not
(t/<
(t/now)
(t/>> (t/now) (t/new-duration 20 :seconds))
(t/>> (t/now) (t/new-duration 10 :seconds)))))
(let [at (t/now)]
(is (t/<= at at (t/>> at (t/new-duration 1 :seconds))))
(is (t/>= at at (t/<< at (t/new-duration 10 :seconds)))))
(testing "durations"
(is (t/> (t/new-duration 20 :seconds) (t/new-duration 10 :seconds)))
(is (t/>= (t/new-duration 20 :seconds) (t/new-duration 20 :seconds)))
(is (t/>= (t/new-duration 20 :seconds) (t/new-duration 19 :seconds)))
(is (not (t/>= (t/new-duration 19 :seconds) (t/new-duration 20 :seconds))))
(is (t/< (t/new-duration 10 :seconds) (t/new-duration 20 :seconds)))
(is (t/<= (t/new-duration 20 :seconds) (t/new-duration 20 :seconds)))
(is (t/<= (t/new-duration 19 :seconds) (t/new-duration 20 :seconds)))
(is (not (t/<= (t/new-duration 20 :seconds) (t/new-duration 19 :seconds))))))
(is (not (t/>= t1 t2)))
(is (t/>= t1 t1))
(is (t/>= t2 t1))))