I am trying to get js-joda working. I copied code from Fulcro and it doesn’t seem to load the timezones successfully. I’ve got:
(ns com.roklenarcic.qrconvert.util.joda
(:require ["@js-joda/core" :as js-joda]))
(set! js/JSJoda js-joda)
Which is required by:
(ns com.roklenarcic.qrconvert.util.joda-tz
(:require [com.roklenarcic.qrconvert.util.joda]
["@js-joda/timezone/dist/js-joda-timezone-10-year-range.min.js"]))
And then the root requires this one and nothing else. Then in the remote repl I try to run this:
(require '[cljc.java-time.local-date-time :as ldt])
=> nil
(ldt/at-zone (ldt/now) "Europe/London")
I get error:
hook.js:608 REPL Invoke Exception TypeError: zone.rules is not a function
at ZonedDateTime.value (js-joda.js:10478:28)
at ZonedDateTime.value (js-joda.js:10459:32)
at ZonedDateTime.value (js-joda.js:10444:38)
at LocalDateTime.value (js-joda.js:12591:32)
at cljc$java_time$local_date_time$at_zone (local_date_time.cljs:34:209)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (shadow.cljs.devtools…ient.browser.js:1:1), <anonymous>:1:40)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (browser.cljs:159:5)
at Object.eval [as shadow$cljs$devtools$client$shared$IHostSpecific$do_invoke$arity$5] (browser.cljs:208:19)
at Object.shadow$cljs$devtools$client$shared$do_invoke [as do_invoke] (shared.cljs:23:15)
I’ve been trying to solve this one for hours now 🙂Have you tried requiring the whole @js-joda/timezone?
Unrelated, but why do you need (set! js/JSJoda js-joda)?
Well I copied this solution from Fulcro RAD, but it’s there because supposedly the js-joda/timezone/dist/js-joda-timezone-10-year-range.min.js requires that object to be present to install the timezones on it
Wicked.
yeah that’s why I’m asking if someone dealt with that, this is too arcane for me and the code that does it is in the minified JS
I’ll try to include the whole timezone thing
but ideally for production build I want to use the minimized version
> the code that does it is in the minified JS Isn't there a non-minified version right beside it? Just to debug this crap.
I’ll try
1. That setting of js/JSJoda is not required
2. Your usage of at-zone is wrong - it requires ZoneId, not a string.
This works:
(ns proj.js-joda
(:require ["@js-joda/core" :as js-joda]
["@js-joda/timezone"]
[cljc.java-time.zone-id :as zone-id]
[cljc.java-time.local-date-time :as ldt]))
(defn main []
(let [zone (zone-id/of "Europe/London")]
(js/console.log (ldt/at-zone (ldt/now) zone))))Oh that fixes that
thank you
> I’ve been trying to solve this one for hours now Don't do that. :) If you're completely stuck with no meaningful progress for more than 15-30 minutes, just reach out. There's always a significantly more than 0 chance that someone will be able to help.