clojurescript

roklenarcic 2025-10-05T17:36:54.407179Z

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 🙂

p-himik 2025-10-05T17:49:54.824609Z

Have you tried requiring the whole @js-joda/timezone?

p-himik 2025-10-05T17:51:08.656139Z

Unrelated, but why do you need (set! js/JSJoda js-joda)?

roklenarcic 2025-10-05T18:10:10.875759Z

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

p-himik 2025-10-05T18:10:43.836209Z

Wicked.

roklenarcic 2025-10-05T18:11:20.475849Z

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

roklenarcic 2025-10-05T18:11:35.848469Z

I’ll try to include the whole timezone thing

roklenarcic 2025-10-05T18:11:50.456739Z

but ideally for production build I want to use the minimized version

p-himik 2025-10-05T18:12:13.126309Z

> 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.

roklenarcic 2025-10-05T18:12:27.007309Z

I’ll try

p-himik 2025-10-05T18:22:29.423589Z

1. That setting of js/JSJoda is not required 2. Your usage of at-zone is wrong - it requires ZoneId, not a string.

👍 1
p-himik 2025-10-05T18:22:35.495489Z

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))))

roklenarcic 2025-10-05T21:13:54.760149Z

Oh that fixes that

roklenarcic 2025-10-05T21:13:56.644309Z

thank you

👍 1
p-himik 2025-10-05T22:07:45.130659Z

> 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.

❤️ 1