Public Vars

Back

micros (clj)

(source)

function

(micros v)
extract micros from 'v'

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 truncate-test
  (let [dates [(t/instant) (t/zoned-date-time) (t/date-time)
               (t/offset-date-time) (t/time)]
        truncate-tos [:nanos
                     :micros
                     :millis
                     :seconds
                     :minutes
                     :hours
                     :half-days
                     :days     ]]
    (doseq [date dates
            truncate-to truncate-tos]
      (is (t/truncate date truncate-to)))))

;; Durations. Convenience functions to create durations of specific
;; units.
(deftest duration-functions-test
  (is (= (t/of-nanos 10) (t/new-duration 10 :nanos)))
  (is (= (t/of-micros 10) (t/new-duration 10 :micros))) ;java.time.Duration doesn't have ofMicros method
  (is (= (t/of-millis 10) (t/new-duration 10 :millis)))
  (is (= (t/of-seconds 10) (t/new-duration 10 :seconds)))
  (is (= (t/of-minutes 10) (t/new-duration 10 :minutes)))
  (is (= (t/of-hours 10) (t/new-duration 10 :hours))))