Public Vars

Back

parse-time (clj)

(source)

function

(parse-time date-str formatter)
to parse an iso-formatted time, use (t/time "20:20..") instead

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 parse-test
  (is (t/date? (t/parse-date "2020/02/02" (t/formatter "yyyy/MM/dd"))))
  (is (t/year? (t/parse-year "20" (t/formatter "yy"))))
  (is (t/year-month? (t/parse-year-month "20/02" (t/formatter "yy/MM"))))
  (is (t/date-time? (t/parse-date-time "2020/02/02:2002" (t/formatter "yyyy/MM/dd:HHmm"))))
  (is (t/time? (t/parse-time "2002" (t/formatter "HHmm"))))
  (is (t/zoned-date-time? (t/parse-zoned-date-time "2020/02/02:2002:Z"
                            (t/formatter "yyyy/MM/dd:HHmm:VV"))))
  (is (t/offset-date-time? (t/parse-offset-date-time "2020/02/02:2002:-08:30"
                             (t/formatter "yyyy/MM/dd:HHmm:VV")))))
borgeby/jarl
(ns jarl.builtins.http-test
  (:require [jarl.builtins.http :refer [builtin-http-send content-type create-request parse-timeout]]
            [jarl.exceptions :as errors]
            [jarl.types :refer [rego-equal?]]
            [jarl.http-client :as http-client]
            [jarl.time :as time]
            #?(:clj  [clojure.test :refer [deftest is testing]]
               :cljs [cljs.test :refer [deftest is testing]])
            [tick.core :as t]))

(deftest parse-timout-test
  (testing "parse timout"
    (is (rego-equal? (parse-timeout "1h")       3600000))
    (is (rego-equal? (parse-timeout "1h1ns")    3600000))
    (is (rego-equal? (parse-timeout "1h1ms")    3600001))
    (is (rego-equal? (parse-timeout "1ns")            1))
    (is (rego-equal? (parse-timeout "1.5m3.5s") 93500))))