Public Vars

Back

format (clj)

(source)

function

(format o) (format fmt o)
Formats the given time entity as a string. Accepts something that can be converted to a `DateTimeFormatter` as a first argument. Given one argument uses the default format.

Examples

tick
(ns tick.addon-libs-test
  (:require
    [tick.core :as t]
    [tick.timezone]
    [tick.locale-en-us]
    [clojure.test
     :refer [deftest is testing run-tests]
     :refer-macros [deftest is testing run-tests]]))

(deftest locale-test 
  (is (t/formatter "yyyy-MMM-dd")))
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 formatting-test
  (testing "all predefined formatters exist"
    (doseq [pre-defined (vals t/predefined-formatters)]
      (is pre-defined)))
  (let [d "3030-05-03"]
    (is (= d (t/format :iso-local-date (t/date d))))
    (is (= d (t/format (t/formatter :iso-local-date) (t/date d))))
    (is (= d (t/format (t/formatter "YYYY-MM-dd") (t/date d))))
    #?(:bb
       ; bb only inlcludes the English Locale by default
       (is (= "3030-May-03" (t/format (t/formatter "YYYY-MMM-dd" java.util.Locale/FRENCH)
                              (t/date d))))
       :clj
       (is (= "3030-mai-03" (t/format (t/formatter "YYYY-MMM-dd" java.util.Locale/FRENCH)
                              (t/date d)))))))

(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")))))
katox/neanderthal-stick
(ns neanderthal-stick.cuda
  (:require [uncomplicate.commons.utils :refer [dragan-says-ex]]
            [uncomplicate.neanderthal.core :as core]
            [uncomplicate.neanderthal.cuda]
            [neanderthal-stick.core :refer [ContainerInfo describe]]
            [neanderthal-stick.internal.common :as common])
  (:import (uncomplicate.neanderthal.internal.device.cublock CUBlockVector CUGEMatrix CUUploMatrix)))

(extend-protocol ContainerInfo
  CUBlockVector
  (describe [x]
    {:kind :vector :entry-type (common/entry-type-kw x) :n (core/dim x)})
  CUGEMatrix
  (describe [x]
    (-> (common/describe-common x) (assoc :m (core/mrows x))))
  CUUploMatrix
  (describe [x]
    (let [{:keys [matrix-type] :as dx} (common/describe-common x)
          {:keys [uplo diag]} (common/region-options x)]
      (case matrix-type
        :tr (update dx :options #(merge % {:uplo uplo :diag diag}))
        :tp (update dx :options #(merge % {:uplo uplo :diag diag}))
        :sp (update dx :options #(merge % {:uplo uplo}))
        :sy (update dx :options #(merge % {:uplo uplo}))
        (dragan-says-ex (format "%s is not a valid matrix type. Please send a bug report." matrix-type)
                        {:type matrix-type})))))