From 84003d87a6c11317dddc50be1472cac6320d72cf Mon Sep 17 00:00:00 2001 From: wizard50 Date: Sun, 13 Oct 2024 19:50:52 -0300 Subject: [PATCH] added prior-open to calendar.core --- lib/calendar/src/ta/calendar/core.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/calendar/src/ta/calendar/core.clj b/lib/calendar/src/ta/calendar/core.clj index b6336505..d79f5598 100644 --- a/lib/calendar/src/ta/calendar/core.clj +++ b/lib/calendar/src/ta/calendar/core.clj @@ -62,6 +62,19 @@ _ (assert dt "current close dt is nil.")] (current-close-dt calendar dt))) +(defn prior-open + "dt needs to be calendar-time, + use current-open to align clock-time to calendar-time" + [[calendar-kw interval-kw] dt] + (let [calendar (calendar-kw calendars) + interval (interval-kw intervals) + _ (assert calendar) + _ (assert interval) + ;_ (println "calendar: " calendar) + ;_ (println "interval: " interval) + prior-open-dt (:prior-open interval)] + (prior-open-dt calendar dt))) + (defn close->open-dt [[calendar-kw interval-kw] & [dt]] (let [dt (if dt dt (t/now)) calendar (calendar-kw calendars)