Back
noon (clj)
(source)function
(noon)
(noon date)
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 time-construction-test
(testing "(time)"
(is (t/time? (t/time))))
(testing "(midnight)"
(is (t/time? (t/midnight)))
(is (= "00:00" (str (t/midnight)))))
(testing "(noon)"
(is (t/time? (t/noon)))
(is (= "12:00" (str (t/noon))))))
(deftest date-construction-test
(is (= (t/date "2018-01-11")
(t/date (t/instant 1515691416624))))
(is (t/date-time? (t/noon (t/today))))
(t/with-clock (-> (t/date "2018-02-14") (t/at "10:00"))
(testing "(noon (today))"
(is (= "2018-02-14T12:00" (str (t/noon (t/today))))))
(testing "(noon (date))"
(is (= "2018-02-14T12:00" (str (t/noon (t/date))))))))
;; Point-in-time tests
(deftest today-test
(t/with-clock (cljc.java-time.clock/fixed (t/instant "2017-08-08T12:00:00Z") t/UTC)
(is (= (t/instant "2017-08-08T12:00:00Z") (t/now)))
(is (= (t/date "2017-08-08") (t/today)))
(is (= (t/date "2017-08-07") (t/yesterday)))
(is (= (t/date "2017-08-09") (t/tomorrow)))
(is (= 8 (t/day-of-month (t/today))))
(is (= 2017 (t/int (t/year))))
(is (= (t/date-time "2017-08-08T12:00:00") (t/noon (t/today))))
(is (= (t/date-time "2017-08-08T00:00:00") (t/midnight (t/today))))))