This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-11
Channels
- # announcements (16)
- # aws (17)
- # babashka (25)
- # beginners (60)
- # calva (40)
- # cider (3)
- # clara (4)
- # clj-kondo (24)
- # clojure (16)
- # clojure-austin (3)
- # clojure-dev (23)
- # clojure-europe (33)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-uk (4)
- # clojurescript (39)
- # clr (108)
- # conjure (10)
- # cursive (12)
- # datalevin (7)
- # editors (2)
- # events (1)
- # fulcro (24)
- # graalvm (3)
- # introduce-yourself (8)
- # london-clojurians (2)
- # malli (18)
- # meander (6)
- # missionary (10)
- # nbb (16)
- # off-topic (19)
- # polylith (1)
- # portal (4)
- # rdf (1)
- # reitit (4)
- # remote-jobs (3)
- # shadow-cljs (10)
- # xtdb (12)
I ran into this strange bug with date-time/set-timezone!
I have a function (change-time [inst local-time])
that returns an inst with the time set to local-time. So for example
(= (dt/html-datetime-string->inst "2023-01-11T00:00:00")
(change-time (dt/html-datetime-string->inst "2023-01-11T11:00:00") local-time/midnight))
When I call set-timezone!
it stops working for all dates before 2015-11-02. Without set-timezone!
it returns correctly. Here's the function:
(ns app.core
(:require
[cljc.java-time.instant :as instant]
[cljc.java-time.local-date-time :as ldt]
[cljc.java-time.local-time :as lt]
[cljc.java-time.zoned-date-time :as zdt]
[cljc.java-time.zone-id :as zone-id]
[com.fulcrologic.rad.type-support.date-time :as dt]))
(defn change-time
[inst local-time]
;; (dt/set-timezone! "America/New_York") ;; Uncomment to cause bug
(let [z (zone-id/of "America/New_York")
instant (instant/of-epoch-milli (inst-ms inst))
dt (ldt/of-instant instant z)
dt (ldt/with dt local-time)
zdt (ldt/at-zone dt z)
millis (instant/to-epoch-milli (zdt/to-instant zdt))
result (js/Date. millis)]
(js/console.log "inst" inst
"dt" (ldt/of-instant instant z)
"dt2" dt
"zdt" zdt
"result" result)
result))
(defn ^:export start
[]
(let [inst (js/Date. 1446350400000) ;; November 1, 2015 12:00:00 AM GMT-04:00
local-time lt/midnight]
;; Should be Sun Nov 01 2015 00:00:00 GMT-0400
;; When broken it is Sat Oct 31 2015 01:00:00 GMT-0400
(js/console.log (change-time inst local-time))))
pretty sure the joda-time database is truncated for compactness…you can install one with more range if you need it. I think that is probably the problem
I feel like somewhere in one of the libraries there should be a warning in the README about this. Idk if it should be js-joda, cljc.java-time, or RAD
Actually probably not the RAD README. That'd be kinda weird. Maybe in the docstring of the date-time module
I don’t know if I’ve removed the selection from the source yet or not…TBH, I guess I should look
So I guess if you require something after that, it’ll override it, but I should figure out some non-breaking way (if possible) to make that better
it’s sort of a bad design to force that optimization onto unsuspecting users 😄 That, and it isn’t much of an optimization if you’re going to end up with both in your compiled bundle 😞
I guess I should require the entire database. The compressed size compared to todays network speeds are probably just not much of a concern. If you don’t use the date-time ns, you won’t get it.
I had another question. So the Fulcro Developers Guide explains how to create components just for their queries using defsc
. But now there's nc
and the even more new defnc
. It looks like some of the components in fulcro have been migrated to nc
, such as FormConfig
. Is the new blessed way to create components just for their queries nc
or is defsc
still preferred?
If you only need a query, then defnc
is lighter weight. It still registers the component so that registry lookups work, which is necessary for UISM and some other bits that want to store the query by registry key instead of component.
The intention of nc
is for complete dynamic systems whre you want to create a query programatically on the fly
I guess that adding something like
> It registers the component so that registry lookups work, which is necessary for UISM and some other bits that want to store the query by registry key instead of component. The intention of nc
is for complete dynamic systems whre you want to create a query programatically on the fly
to the defnc docstring would be very helpful for users to understand whether to use this or nc
. no?