Skip to content

Commit

Permalink
same tests passing with java.time
Browse files Browse the repository at this point in the history
  • Loading branch information
henryw374 committed Nov 22, 2023
1 parent dfc7f3f commit f38dbef
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 161 deletions.
40 changes: 12 additions & 28 deletions dev/com/widdindustries/gen/gen/accessors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@

(def kw->class
{
'date LocalDate
'timezone ZoneId
'zdt ZonedDateTime
'instant Instant
'time LocalTime
'monthday MonthDay
'datetime LocalDateTime
'yearmonth YearMonth
'date 'LocalDate
'timezone 'ZoneId
'zdt 'ZonedDateTime
'instant 'Instant
'time 'LocalTime
'monthday 'MonthDay
'datetime 'LocalDateTime
'yearmonth 'YearMonth
})

(def kw->cljc-ns
Expand Down Expand Up @@ -130,7 +130,7 @@
(if-let [x (special-accessor (get target feature))]
x
(if-let [target-class (get kw->class target-name)]
(str ".to" (.getSimpleName target-class))
(str ".to" (str target-class))
(str ".get" (upper-first (csk/->camelCaseString (name target-name))))))) foo))))))

(defn accessor-forms [feature]
Expand Down Expand Up @@ -160,21 +160,14 @@
(~(symbol parser) foo)))
)))

(comment
(parse-fn :cljay (ffirst full-paths)))

(defn parse-forms [feature]
(->> (apply concat full-paths)
distinct
(keep (fn [thing]
(parse-fn feature thing))))


; (defn duration-parse [s]
; #?(:clj (Duration/parse s)
; :cljs (methods/from entities/duration s)))
;
; (defn period-parse [s]
; #?(:clj (Period/parse s)
; :cljs (duration-parse s)))
;
)

(defn now-fn [feature subject]
Expand All @@ -184,15 +177,6 @@
:cljay (str (get kw->class (:tempo subject)) "/" (or (-> subject feature :parse) "now"))
:cljs (str "clock/"(:tempo subject) )
:cljc (str (get kw->cljc-ns (:tempo subject)) "/" (or (-> subject feature :parse) "now")))]
;; construction from clocks
; (defn date-now
; ([] #?(:clj (LocalDate/now)
; :cljs (clock/plain-date-iso)))
; ([clock]
; #?(:clj (LocalDate/now ^Clock clock)
; :cljs (clock/plain-date-iso clock))))
;

(backtick/template
(defn ~(symbol fn-name)
([] (~(symbol nower)))
Expand Down
4 changes: 3 additions & 1 deletion dev/com/widdindustries/gen/gen_in/tempo.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
""
(:refer-clojure :exclude [min max > < >= <= >> <<])
#?(:cljay
(:import (java.time LocalDateTime ZonedDateTime))
(:import
[java.time Clock MonthDay ZoneId ZoneOffset Instant Duration Period DayOfWeek Month ZonedDateTime LocalTime LocalDateTime LocalDate Year YearMonth ZoneId OffsetDateTime OffsetTime]
[java.time.temporal Temporal TemporalAmount])
:cljc (:require
[cljc.java-time.local-date]
[cljc.java-time.local-date-time]
Expand Down
4 changes: 1 addition & 3 deletions dev/com/widdindustries/gen/graph.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
(ns com.widdindustries.gen.graph
(:require [clojure.walk]
[sc.api])
(:require [clojure.walk])
(:import (java.time ZonedDateTime MonthDay DayOfWeek YearMonth)))


(defn parts->paths [parent-key parts]
(->> parts
(mapcat (fn [[k v]]
Expand Down
4 changes: 0 additions & 4 deletions dev/com/widdindustries/gen/graph_gen.clj

This file was deleted.

Loading

0 comments on commit f38dbef

Please sign in to comment.