From 41fccb6ee53404536921415214d23e6a24fea756 Mon Sep 17 00:00:00 2001 From: Henry Widd Date: Wed, 21 Feb 2024 16:19:28 +0000 Subject: [PATCH] tz as strings in passing in/out of fns other than when working directly with zones --- dev/com/widdindustries/gen/gen/accessors.clj | 4 +- gen_in/constructors.cljc | 8 +- src/com/widdindustries/tempo.clj | 190 +++++++++---- src/com/widdindustries/tempo.cljs | 275 +++++++++++-------- test/com/widdindustries/tempo_gen_test.cljc | 64 ++--- test/com/widdindustries/tempo_test.cljc | 2 +- 6 files changed, 337 insertions(+), 206 deletions(-) diff --git a/dev/com/widdindustries/gen/gen/accessors.clj b/dev/com/widdindustries/gen/gen/accessors.clj index 5f719d1..9b51aac 100644 --- a/dev/com/widdindustries/gen/gen/accessors.clj +++ b/dev/com/widdindustries/gen/gen/accessors.clj @@ -87,8 +87,8 @@ (defn special-accessor [target] (cond (:xform-fn target) (:xform-fn target) - (:accessor target) (str "." (:accessor target)) - :else nil)) + (:accessor target) (symbol (str "." (:accessor target))) + :else nil)) (defn cljc-accessor [feature path] (let [subject (:tempo (first path)) diff --git a/gen_in/constructors.cljc b/gen_in/constructors.cljc index b66a6ce..671bc7c 100644 --- a/gen_in/constructors.cljc +++ b/gen_in/constructors.cljc @@ -1,5 +1,7 @@ (ns com.widdindustries.gen.gen-in.constructors - #?(:cljay (:import (java.time LocalDateTime ZonedDateTime)))) + #?(:cljay (:import (java.time LocalDateTime ZonedDateTime))) + (:require [com.widdindustries.tempo :as t] + [com.widdindustries.tempo :as t])) (defn time-from [thing] (let [hour (get thing :hour 0) @@ -41,8 +43,8 @@ (defn zdt-from [thing] (let [ldt (or (get thing :datetime) (datetime-from thing)) - zone (get thing :timezone)] - #?(:cljay (ZonedDateTime/of ^LocalDateTime ldt ^ZoneId zone) + zone (get thing :timezone)] + #?(:cljay (ZonedDateTime/of ^LocalDateTime ldt ^ZoneId (timezone-parse zone)) :cljs (.toZonedDateTime ^js ldt zone) :cljc (cljc.java-time.zoned-date-time/of ^LocalDateTime ldt ^ZoneId zone)))) diff --git a/src/com/widdindustries/tempo.clj b/src/com/widdindustries/tempo.clj index b52d6fa..0dd55e5 100644 --- a/src/com/widdindustries/tempo.clj +++ b/src/com/widdindustries/tempo.clj @@ -22,7 +22,12 @@ ZoneId OffsetDateTime OffsetTime] - [java.time.temporal Temporal TemporalAmount TemporalUnit ChronoUnit] + [java.time.temporal + Temporal + TemporalAmount + TemporalUnit + ChronoUnit + ChronoField] [java.util Date])) (set! *warn-on-reflection* true) @@ -62,15 +67,17 @@ [] (Clock/systemDefaultZone)) +(defn clock-offset [offset-or-zone]) + (defn greater [x y] (if (neg? (compare x y)) y x)) (defn max - "Find the latest of the given arguments. Callers should ensure that no\n argument is nil." + "Find the latest of the given arguments. Callers should ensure that no\r\n argument is nil." [arg & args] (assert (every? some? (cons arg args))) (reduce - (fn* [p1__81481# p2__81482#] (greater p1__81481# p2__81482#)) + (fn* [p1__38368# p2__38369#] (greater p1__38368# p2__38369#)) arg args)) @@ -78,11 +85,11 @@ (defn min - "Find the earliest of the given arguments. Callers should ensure that no\n argument is nil." + "Find the earliest of the given arguments. Callers should ensure that no\r\n argument is nil." [arg & args] (assert (every? some? (cons arg args))) (reduce - (fn* [p1__81483# p2__81484#] (lesser p1__81483# p2__81484#)) + (fn* [p1__38370# p2__38371#] (lesser p1__38370# p2__38371#)) arg args)) @@ -144,39 +151,103 @@ (unit-amount [_]) (unit-accessor [_ x])) -(def nanos-unit ChronoUnit/NANOS) +(defprotocol Property (unit [_]) (field [_])) + +(def + nanos-property + (reify + Property + (unit [_] ChronoUnit/NANOS) + (field [_] ChronoField/NANO_OF_SECOND))) + +(def + micros-property + (reify + Property + (unit [_] ChronoUnit/MICROS) + (field [_] ChronoField/MICRO_OF_SECOND))) -(def micros-unit ChronoUnit/MICROS) +(def + millis-property + (reify + Property + (unit [_] ChronoUnit/MILLIS) + (field [_] ChronoField/MILLI_OF_SECOND))) -(def millis-unit ChronoUnit/MILLIS) +(def + seconds-property + (reify + Property + (unit [_] ChronoUnit/SECONDS) + (field [_] ChronoField/SECOND_OF_MINUTE))) -(def seconds-unit ChronoUnit/SECONDS) +(def + minutes-property + (reify + Property + (unit [_] ChronoUnit/MINUTES) + (field [_] ChronoField/MINUTE_OF_HOUR))) -(def minutes-unit ChronoUnit/MINUTES) +(def + hours-property + (reify + Property + (unit [_] ChronoUnit/HOURS) + (field [_] ChronoField/HOUR_OF_DAY))) -(def hours-unit ChronoUnit/HOURS) +(def + days-property + (reify + Property + (unit [_] ChronoUnit/DAYS) + (field [_] ChronoField/DAY_OF_MONTH))) -(def days-unit ChronoUnit/DAYS) +(def + months-property + (reify + Property + (unit [_] ChronoUnit/MONTHS) + (field [_] ChronoField/MONTH_OF_YEAR))) -(def months-unit ChronoUnit/MONTHS) +(def + years-property + (reify + Property + (unit [_] ChronoUnit/YEARS) + (field [_] ChronoField/YEAR))) -(def years-unit ChronoUnit/YEARS) +(defn + with + [temporal value property] + (.with + ^Temporal temporal + ^{:tag TemporalField} + (field property) + ^long value)) -(defn until [v1 v2 unit] (.until ^Temporal v1 v2 unit)) +(defn until [v1 v2 property] (.until ^Temporal v1 v2 (unit property))) (defn >> ([temporal temporal-amount] (.plus ^Temporal temporal ^TemporalAmount temporal-amount)) - ([temporal amount temporal-unit] - (.plus ^Temporal temporal amount ^TemporalUnit temporal-unit))) + ([temporal amount temporal-property] + (.plus + ^Temporal temporal + amount + ^{:tag TemporalUnit} + (unit temporal-property)))) (defn << ([temporal temporal-amount] (.minus ^Temporal temporal ^TemporalAmount temporal-amount)) - ([temporal amount temporal-unit] - (.minus ^Temporal temporal amount ^TemporalUnit temporal-unit))) + ([temporal amount temporal-property] + (.minus + ^Temporal temporal + amount + ^{:tag TemporalUnit} + (unit temporal-property)))) (defprotocol WeekDay (weekday-number [_]) (english-name [_])) @@ -212,30 +283,28 @@ ^{:line 31, :column 9} (comment "accessors") +(defn date->month [^LocalDate foo] (-> foo .getMonthValue)) + +(defn yearmonth->month [^YearMonth foo] (-> foo .getMonthValue)) + +(defn zdt->month [^ZonedDateTime foo] (-> foo .getMonthValue)) + (defn datetime->second [^LocalDateTime foo] (-> foo .getSecond)) (defn zdt->date [^ZonedDateTime foo] (-> foo .toLocalDate)) -(defn monthday->month [^MonthDay foo] (-> foo ".getMonthValue")) - (defn datetime->year [^LocalDateTime foo] (-> foo .getYear)) -(defn datetime->month [^LocalDateTime foo] (-> foo ".getMonthValue")) +(defn datetime->month [^LocalDateTime foo] (-> foo .getMonthValue)) -(defn zdt->year [^ZonedDateTime foo] (-> foo .getYear)) - -(defn date->month [^LocalDate foo] (-> foo ".getMonthValue")) +(defn monthday->day-of-month [^MonthDay foo] (-> foo .getDayOfMonth)) -(defn yearmonth->month [^YearMonth foo] (-> foo ".getMonthValue")) +(defn zdt->year [^ZonedDateTime foo] (-> foo .getYear)) (defn datetime->hour [^LocalDateTime foo] (-> foo .getHour)) -(defn yearmonth->year [^YearMonth foo] (-> foo .getYear)) - (defn date->day-of-month [^LocalDate foo] (-> foo .getDayOfMonth)) -(defn zdt->day-of-month [^ZonedDateTime foo] (-> foo .getDayOfMonth)) - (defn zdt->hour [^ZonedDateTime foo] (-> foo .getHour)) (defn zdt->instant [^ZonedDateTime foo] (-> foo .toInstant)) @@ -247,8 +316,6 @@ [^ZonedDateTime foo] (-> foo (-> (.getDayOfWeek) (.getValue)))) -(defn zdt->month [^ZonedDateTime foo] (-> foo ".getMonthValue")) - (defn zdt->minute [^ZonedDateTime foo] (-> foo .getMinute)) (defn @@ -256,18 +323,15 @@ [^LocalDateTime foo] (-> foo .getDayOfMonth)) -(defn date->year [^LocalDate foo] (-> foo .getYear)) - (defn datetime->date [^LocalDateTime foo] (-> foo .toLocalDate)) -(defn - zdt->timezone - [^ZonedDateTime foo] - (-> foo (-> (.getZone) (.getId)))) +(defn date->year [^LocalDate foo] (-> foo .getYear)) (defn zdt->second [^ZonedDateTime foo] (-> foo .getSecond)) -(defn instant->epochmilli [^Instant foo] (-> foo ".toEpochMilli")) +(defn zdt->day-of-month [^ZonedDateTime foo] (-> foo .getDayOfMonth)) + +(defn instant->epochmilli [^Instant foo] (-> foo .toEpochMilli)) (defn time->second [^LocalTime foo] (-> foo .getSecond)) @@ -278,6 +342,11 @@ (defn zdt->datetime [^ZonedDateTime foo] (-> foo .toLocalDateTime)) +(defn + zdt->timezone + [^ZonedDateTime foo] + (-> foo (-> (.getZone) (.getId)))) + (defn zdt->time [^ZonedDateTime foo] (-> foo .toLocalTime)) (defn datetime->minute [^LocalDateTime foo] (-> foo .getMinute)) @@ -295,25 +364,27 @@ (defn time->hour [^LocalTime foo] (-> foo .getHour)) +(defn monthday->month [^MonthDay foo] (-> foo .getMonthValue)) + (defn datetime->nano [^LocalDateTime foo] (-> foo .getNano)) -(defn datetime->time [^LocalDateTime foo] (-> foo .toLocalTime)) +(defn yearmonth->year [^YearMonth foo] (-> foo .getYear)) -(defn monthday->day-of-month [^MonthDay foo] (-> foo .getDayOfMonth)) +(defn datetime->time [^LocalDateTime foo] (-> foo .toLocalTime)) ^{:line 33, :column 9} (comment "parsers") -(defn datetime-parse [^java.lang.String foo] (LocalDateTime/parse foo)) +(defn date-parse [^java.lang.String foo] (LocalDate/parse foo)) -(defn time-parse [^java.lang.String foo] (LocalTime/parse foo)) +(defn yearmonth-parse [^java.lang.String foo] (YearMonth/parse foo)) (defn zdt-parse [^java.lang.String foo] (ZonedDateTime/parse foo)) -(defn date-parse [^java.lang.String foo] (LocalDate/parse foo)) +(defn datetime-parse [^java.lang.String foo] (LocalDateTime/parse foo)) (defn monthday-parse [^java.lang.String foo] (MonthDay/parse foo)) -(defn yearmonth-parse [^java.lang.String foo] (YearMonth/parse foo)) +(defn time-parse [^java.lang.String foo] (LocalTime/parse foo)) (defn instant-parse [^java.lang.String foo] (Instant/parse foo)) @@ -322,14 +393,14 @@ ^{:line 35, :column 9} (comment "nowers") (defn - datetime-now - ([] (LocalDateTime/now)) - ([^java.time.Clock clock] (LocalDateTime/now clock))) + date-now + ([] (LocalDate/now)) + ([^java.time.Clock clock] (LocalDate/now clock))) (defn - time-now - ([] (LocalTime/now)) - ([^java.time.Clock clock] (LocalTime/now clock))) + yearmonth-now + ([] (YearMonth/now)) + ([^java.time.Clock clock] (YearMonth/now clock))) (defn zdt-now @@ -337,9 +408,9 @@ ([^java.time.Clock clock] (ZonedDateTime/now clock))) (defn - date-now - ([] (LocalDate/now)) - ([^java.time.Clock clock] (LocalDate/now clock))) + datetime-now + ([] (LocalDateTime/now)) + ([^java.time.Clock clock] (LocalDateTime/now clock))) (defn monthday-now @@ -347,9 +418,9 @@ ([^java.time.Clock clock] (MonthDay/now clock))) (defn - yearmonth-now - ([] (YearMonth/now)) - ([^java.time.Clock clock] (YearMonth/now clock))) + time-now + ([] (LocalTime/now)) + ([^java.time.Clock clock] (LocalTime/now clock))) (defn instant-now @@ -407,7 +478,10 @@ (or (get thing :datetime) (datetime-from thing)) zone (get thing :timezone)] - (ZonedDateTime/of ^LocalDateTime ldt ^ZoneId zone))) + (ZonedDateTime/of + ^LocalDateTime ldt + ^{:tag ZoneId} + (timezone-parse zone)))) (defn instant-from diff --git a/src/com/widdindustries/tempo.cljs b/src/com/widdindustries/tempo.cljs index e7a3bcb..626993a 100644 --- a/src/com/widdindustries/tempo.cljs +++ b/src/com/widdindustries/tempo.cljs @@ -40,15 +40,17 @@ [] js/Temporal.Now) +(defn clock-offset [offset-or-zone]) + (defn greater [x y] (if (neg? (compare x y)) y x)) (defn max - "Find the latest of the given arguments. Callers should ensure that no\n argument is nil." + "Find the latest of the given arguments. Callers should ensure that no\r\n argument is nil." [arg & args] (assert (every? some? (cons arg args))) (reduce - (fn* [p1__81485# p2__81486#] (greater p1__81485# p2__81486#)) + (fn* [p1__38372# p2__38373#] (greater p1__38372# p2__38373#)) arg args)) @@ -56,11 +58,11 @@ (defn min - "Find the earliest of the given arguments. Callers should ensure that no\n argument is nil." + "Find the earliest of the given arguments. Callers should ensure that no\r\n argument is nil." [arg & args] (assert (every? some? (cons arg args))) (reduce - (fn* [p1__81487# p2__81488#] (lesser p1__81487# p2__81488#)) + (fn* [p1__38374# p2__38375#] (lesser p1__38374# p2__38375#)) arg args)) @@ -122,99 +124,155 @@ (unit-amount [_]) (unit-accessor [_ x])) +(defprotocol Property (unit [_]) (field [_])) + (def - nanos-unit + nanos-property (reify - Unit - (unit-amount [_] "nanoseconds") - (unit-field [_] "nanosecond") - (unit-accessor [_ ^js x] (.-nanos x)))) + Property + (field [_] "nanosecond") + (unit + [_] + (reify + Unit + (unit-amount [_] "nanoseconds") + (unit-field [_] "nanosecond") + (unit-accessor [_ ^js x] (.-nanos x)))))) (def - micros-unit + micros-property (reify - Unit - (unit-amount [_] "microseconds") - (unit-field [_] "microsecond") - (unit-accessor [_ ^js x] (.-micros x)))) + Property + (field [_] "microsecond") + (unit + [_] + (reify + Unit + (unit-amount [_] "microseconds") + (unit-field [_] "microsecond") + (unit-accessor [_ ^js x] (.-micros x)))))) (def - millis-unit + millis-property (reify - Unit - (unit-amount [_] "milliseconds") - (unit-field [_] "millisecond") - (unit-accessor [_ ^js x] (.-millis x)))) + Property + (field [_] "millisecond") + (unit + [_] + (reify + Unit + (unit-amount [_] "milliseconds") + (unit-field [_] "millisecond") + (unit-accessor [_ ^js x] (.-millis x)))))) (def - seconds-unit + seconds-property (reify - Unit - (unit-amount [_] "seconds") - (unit-field [_] "second") - (unit-accessor [_ ^js x] (.-seconds x)))) + Property + (field [_] "second") + (unit + [_] + (reify + Unit + (unit-amount [_] "seconds") + (unit-field [_] "second") + (unit-accessor [_ ^js x] (.-seconds x)))))) (def - minutes-unit + minutes-property (reify - Unit - (unit-amount [_] "minutes") - (unit-field [_] "minute") - (unit-accessor [_ ^js x] (.-minutes x)))) + Property + (field [_] "minute") + (unit + [_] + (reify + Unit + (unit-amount [_] "minutes") + (unit-field [_] "minute") + (unit-accessor [_ ^js x] (.-minutes x)))))) (def - hours-unit + hours-property (reify - Unit - (unit-amount [_] "hours") - (unit-field [_] "hour") - (unit-accessor [_ ^js x] (.-hours x)))) + Property + (field [_] "hour") + (unit + [_] + (reify + Unit + (unit-amount [_] "hours") + (unit-field [_] "hour") + (unit-accessor [_ ^js x] (.-hours x)))))) (def - days-unit + days-property (reify - Unit - (unit-amount [_] "days") - (unit-field [_] "day") - (unit-accessor [_ ^js x] (.-days x)))) + Property + (field [_] "day") + (unit + [_] + (reify + Unit + (unit-amount [_] "days") + (unit-field [_] "day") + (unit-accessor [_ ^js x] (.-days x)))))) (def - months-unit + months-property (reify - Unit - (unit-amount [_] "months") - (unit-field [_] "month") - (unit-accessor [_ ^js x] (.-months x)))) + Property + (field [_] "month") + (unit + [_] + (reify + Unit + (unit-amount [_] "months") + (unit-field [_] "month") + (unit-accessor [_ ^js x] (.-months x)))))) (def - years-unit + years-property (reify - Unit - (unit-amount [_] "years") - (unit-field [_] "year") - (unit-accessor [_ ^js x] (.-years x)))) + Property + (field [_] "year") + (unit + [_] + (reify + Unit + (unit-amount [_] "years") + (unit-field [_] "year") + (unit-accessor [_ ^js x] (.-years x)))))) + +(defn + with + [temporal value property] + (.with ^js temporal (js-obj (field property) value))) (defn until - [v1 v2 unit] + [v1 v2 property] (-> (.until ^js v1 ^js v2 - #js {:smallestUnit (unit-field unit), :largestUnit (unit-field unit)}) - (unit-accessor unit))) + #js {:smallestUnit (unit-field (unit property)), :largestUnit (unit-field (unit property))}) + (unit-accessor (unit property)))) (defn >> ([temporal temporal-amount] (.add ^js temporal temporal-amount)) - ([temporal amount temporal-unit] - (.add ^js temporal (js-obj (unit-amount temporal-unit) amount)))) + ([temporal amount temporal-property] + (.add + ^js temporal + (js-obj (unit-amount (unit temporal-property)) amount)))) (defn << ([temporal temporal-amount] (.subtract ^js temporal temporal-amount)) - ([temporal amount temporal-unit] - (.subtract ^js temporal (js-obj (unit-amount temporal-unit) amount)))) + ([temporal amount temporal-property] + (.subtract + ^js temporal + (js-obj (unit-amount (unit temporal-property)) amount)))) (defprotocol WeekDay (weekday-number [_]) (english-name [_])) @@ -258,6 +316,15 @@ ^{:line 31, :column 9} (comment "accessors") +(defn date->month [^js/Temporal.PlainDate foo] (-> foo .-month)) + +(defn + yearmonth->month + [^js/Temporal.PlainYearMonth foo] + (-> foo .-month)) + +(defn zdt->month [^js/Temporal.ZonedDateTime foo] (-> foo .-month)) + (defn datetime->second [^js/Temporal.PlainDateTime foo] @@ -265,31 +332,20 @@ (defn zdt->date [^js/Temporal.ZonedDateTime foo] (-> foo .toPlainDate)) -(defn monthday->month [^js/Temporal.PlainMonthDay foo] (-> foo .-month)) - (defn datetime->year [^js/Temporal.PlainDateTime foo] (-> foo .-year)) (defn datetime->month [^js/Temporal.PlainDateTime foo] (-> foo .-month)) -(defn zdt->year [^js/Temporal.ZonedDateTime foo] (-> foo .-year)) - -(defn date->month [^js/Temporal.PlainDate foo] (-> foo .-month)) - (defn - yearmonth->month - [^js/Temporal.PlainYearMonth foo] - (-> foo .-month)) - -(defn datetime->hour [^js/Temporal.PlainDateTime foo] (-> foo .-hour)) + monthday->day-of-month + [^js/Temporal.PlainMonthDay foo] + (-> foo .-day)) -(defn yearmonth->year [^js/Temporal.PlainYearMonth foo] (-> foo .-year)) +(defn zdt->year [^js/Temporal.ZonedDateTime foo] (-> foo .-year)) -(defn date->day-of-month [^js/Temporal.PlainDate foo] (-> foo ".-day")) +(defn datetime->hour [^js/Temporal.PlainDateTime foo] (-> foo .-hour)) -(defn - zdt->day-of-month - [^js/Temporal.ZonedDateTime foo] - (-> foo ".-day")) +(defn date->day-of-month [^js/Temporal.PlainDate foo] (-> foo .-day)) (defn zdt->hour [^js/Temporal.ZonedDateTime foo] (-> foo .-hour)) @@ -300,31 +356,26 @@ (defn zdt->day-of-week [^js/Temporal.ZonedDateTime foo] - (-> foo ".-dayOfWeek")) - -(defn zdt->month [^js/Temporal.ZonedDateTime foo] (-> foo .-month)) + (-> foo .-dayOfWeek)) (defn zdt->minute [^js/Temporal.ZonedDateTime foo] (-> foo .-minute)) (defn datetime->day-of-month [^js/Temporal.PlainDateTime foo] - (-> foo ".-day")) - -(defn date->year [^js/Temporal.PlainDate foo] (-> foo .-year)) + (-> foo .-day)) (defn datetime->date [^js/Temporal.PlainDateTime foo] (-> foo .toPlainDate)) -(defn - zdt->timezone - [^js/Temporal.ZonedDateTime foo] - (-> foo "..-timeZoneId")) +(defn date->year [^js/Temporal.PlainDate foo] (-> foo .-year)) (defn zdt->second [^js/Temporal.ZonedDateTime foo] (-> foo .-second)) +(defn zdt->day-of-month [^js/Temporal.ZonedDateTime foo] (-> foo .-day)) + (defn instant->epochmilli [^js/Temporal.Instant foo] @@ -335,13 +386,18 @@ (defn date->day-of-week [^js/Temporal.PlainDate foo] - (-> foo ".-dayOfWeek")) + (-> foo .-dayOfWeek)) (defn zdt->datetime [^js/Temporal.ZonedDateTime foo] (-> foo .toPlainDateTime)) +(defn + zdt->timezone + [^js/Temporal.ZonedDateTime foo] + (-> foo .-timeZoneId)) + (defn zdt->time [^js/Temporal.ZonedDateTime foo] (-> foo .toPlainTime)) (defn @@ -357,7 +413,7 @@ (defn datetime->day-of-week [^js/Temporal.PlainDateTime foo] - (-> foo ".-dayOfWeek")) + (-> foo .-dayOfWeek)) (defn time->nano [^js/Temporal.PlainTime foo] (-> foo .-nano)) @@ -365,29 +421,28 @@ (defn time->hour [^js/Temporal.PlainTime foo] (-> foo .-hour)) +(defn monthday->month [^js/Temporal.PlainMonthDay foo] (-> foo .-month)) + (defn datetime->nano [^js/Temporal.PlainDateTime foo] (-> foo .-nano)) +(defn yearmonth->year [^js/Temporal.PlainYearMonth foo] (-> foo .-year)) + (defn datetime->time [^js/Temporal.PlainDateTime foo] (-> foo .toPlainTime)) -(defn - monthday->day-of-month - [^js/Temporal.PlainMonthDay foo] - (-> foo ".-day")) - ^{:line 33, :column 9} (comment "parsers") (defn - datetime-parse + date-parse [^java.lang.String foo] - (js/Temporal.PlainDateTime.from foo)) + (js/Temporal.PlainDate.from foo)) (defn - time-parse + yearmonth-parse [^java.lang.String foo] - (js/Temporal.PlainTime.from foo)) + (js/Temporal.PlainYearMonth.from foo)) (defn zdt-parse @@ -395,9 +450,9 @@ (js/Temporal.ZonedDateTime.from foo)) (defn - date-parse + datetime-parse [^java.lang.String foo] - (js/Temporal.PlainDate.from foo)) + (js/Temporal.PlainDateTime.from foo)) (defn monthday-parse @@ -405,9 +460,9 @@ (js/Temporal.PlainMonthDay.from foo)) (defn - yearmonth-parse + time-parse [^java.lang.String foo] - (js/Temporal.PlainYearMonth.from foo)) + (js/Temporal.PlainTime.from foo)) (defn instant-parse @@ -422,14 +477,14 @@ ^{:line 35, :column 9} (comment "nowers") (defn - datetime-now - ([] (clock/datetime)) - ([^java.time.Clock clock] (clock/datetime clock))) + date-now + ([] (clock/date)) + ([^java.time.Clock clock] (clock/date clock))) (defn - time-now - ([] (clock/time)) - ([^java.time.Clock clock] (clock/time clock))) + yearmonth-now + ([] (clock/yearmonth)) + ([^java.time.Clock clock] (clock/yearmonth clock))) (defn zdt-now @@ -437,9 +492,9 @@ ([^java.time.Clock clock] (clock/zdt clock))) (defn - date-now - ([] (clock/date)) - ([^java.time.Clock clock] (clock/date clock))) + datetime-now + ([] (clock/datetime)) + ([^java.time.Clock clock] (clock/datetime clock))) (defn monthday-now @@ -447,9 +502,9 @@ ([^java.time.Clock clock] (clock/monthday clock))) (defn - yearmonth-now - ([] (clock/yearmonth)) - ([^java.time.Clock clock] (clock/yearmonth clock))) + time-now + ([] (clock/time)) + ([^java.time.Clock clock] (clock/time clock))) (defn instant-now diff --git a/test/com/widdindustries/tempo_gen_test.cljc b/test/com/widdindustries/tempo_gen_test.cljc index 98286c0..36faf0e 100644 --- a/test/com/widdindustries/tempo_gen_test.cljc +++ b/test/com/widdindustries/tempo_gen_test.cljc @@ -11,16 +11,16 @@ ^{:line 53, :column 9} (comment "parsers") (deftest - datetime-parse-test + date-parse-test (let - [now-now (t/datetime-now)] - (is (= now-now (-> now-now str t/datetime-parse))))) + [now-now (t/date-now)] + (is (= now-now (-> now-now str t/date-parse))))) (deftest - time-parse-test + yearmonth-parse-test (let - [now-now (t/time-now)] - (is (= now-now (-> now-now str t/time-parse))))) + [now-now (t/yearmonth-now)] + (is (= now-now (-> now-now str t/yearmonth-parse))))) (deftest zdt-parse-test @@ -29,10 +29,10 @@ (is (= now-now (-> now-now str t/zdt-parse))))) (deftest - date-parse-test + datetime-parse-test (let - [now-now (t/date-now)] - (is (= now-now (-> now-now str t/date-parse))))) + [now-now (t/datetime-now)] + (is (= now-now (-> now-now str t/datetime-parse))))) (deftest monthday-parse-test @@ -41,10 +41,10 @@ (is (= now-now (-> now-now str t/monthday-parse))))) (deftest - yearmonth-parse-test + time-parse-test (let - [now-now (t/yearmonth-now)] - (is (= now-now (-> now-now str t/yearmonth-parse))))) + [now-now (t/time-now)] + (is (= now-now (-> now-now str t/time-parse))))) (deftest instant-parse-test @@ -62,8 +62,8 @@ ^{:line 55, :column 9} (comment "nowers") (deftest - datetime-now-test - (let [now-now (t/datetime-now)] (is (t/datetime? now-now))) + date-now-test + (let [now-now (t/date-now)] (is (t/date? now-now))) (let [clock-1 (t/clock-fixed @@ -74,15 +74,15 @@ (t/instant-parse "1955-12-02T17:46:08.017143Z") (t/zone-system-default)) now-clock-1 - (t/datetime-now clock-1) + (t/date-now clock-1) now-clock-2 - (t/datetime-now clock-2)] - (is (t/datetime? now-clock-1)) + (t/date-now clock-2)] + (is (t/date? now-clock-1)) (is (t/> now-clock-2 now-clock-1)))) (deftest - time-now-test - (let [now-now (t/time-now)] (is (t/time? now-now))) + yearmonth-now-test + (let [now-now (t/yearmonth-now)] (is (t/yearmonth? now-now))) (let [clock-1 (t/clock-fixed @@ -93,10 +93,10 @@ (t/instant-parse "1955-12-02T17:46:08.017143Z") (t/zone-system-default)) now-clock-1 - (t/time-now clock-1) + (t/yearmonth-now clock-1) now-clock-2 - (t/time-now clock-2)] - (is (t/time? now-clock-1)) + (t/yearmonth-now clock-2)] + (is (t/yearmonth? now-clock-1)) (is (t/> now-clock-2 now-clock-1)))) (deftest @@ -119,8 +119,8 @@ (is (t/> now-clock-2 now-clock-1)))) (deftest - date-now-test - (let [now-now (t/date-now)] (is (t/date? now-now))) + datetime-now-test + (let [now-now (t/datetime-now)] (is (t/datetime? now-now))) (let [clock-1 (t/clock-fixed @@ -131,10 +131,10 @@ (t/instant-parse "1955-12-02T17:46:08.017143Z") (t/zone-system-default)) now-clock-1 - (t/date-now clock-1) + (t/datetime-now clock-1) now-clock-2 - (t/date-now clock-2)] - (is (t/date? now-clock-1)) + (t/datetime-now clock-2)] + (is (t/datetime? now-clock-1)) (is (t/> now-clock-2 now-clock-1)))) (deftest @@ -157,8 +157,8 @@ (is (t/> now-clock-2 now-clock-1)))) (deftest - yearmonth-now-test - (let [now-now (t/yearmonth-now)] (is (t/yearmonth? now-now))) + time-now-test + (let [now-now (t/time-now)] (is (t/time? now-now))) (let [clock-1 (t/clock-fixed @@ -169,10 +169,10 @@ (t/instant-parse "1955-12-02T17:46:08.017143Z") (t/zone-system-default)) now-clock-1 - (t/yearmonth-now clock-1) + (t/time-now clock-1) now-clock-2 - (t/yearmonth-now clock-2)] - (is (t/yearmonth? now-clock-1)) + (t/time-now clock-2)] + (is (t/time? now-clock-1)) (is (t/> now-clock-2 now-clock-1)))) (deftest diff --git a/test/com/widdindustries/tempo_test.cljc b/test/com/widdindustries/tempo_test.cljc index b6846b8..e613f4c 100644 --- a/test/com/widdindustries/tempo_test.cljc +++ b/test/com/widdindustries/tempo_test.cljc @@ -28,7 +28,7 @@ ) (testing "level 3" (let [ym (t/yearmonth-now) - timezone (t/zone-system-default) + timezone (str (t/zone-system-default)) zdt (t/zdt-from {:yearmonth ym :day-of-month 1 :hour 1 :timezone timezone})]