This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-09
Channels
- # announcements (2)
- # babashka (33)
- # beginners (122)
- # bristol-clojurians (1)
- # calva (6)
- # chlorine-clover (3)
- # cider (45)
- # clara (10)
- # clj-kondo (3)
- # cljsrn (17)
- # clojure (80)
- # clojure-dev (21)
- # clojure-europe (86)
- # clojure-italy (5)
- # clojure-japan (5)
- # clojure-losangeles (7)
- # clojure-nl (5)
- # clojure-portugal (3)
- # clojure-uk (31)
- # clojurescript (30)
- # conjure (4)
- # core-async (29)
- # cursive (20)
- # data-science (25)
- # datomic (7)
- # duct (17)
- # figwheel-main (73)
- # fulcro (23)
- # jobs-discuss (36)
- # juxt (5)
- # kaocha (2)
- # lambdaisland (6)
- # luminus (5)
- # malli (17)
- # mount (10)
- # music (7)
- # off-topic (16)
- # re-frame (30)
- # ring (17)
- # rum (1)
- # shadow-cljs (10)
- # spacemacs (10)
- # specmonstah (4)
- # sql (45)
- # tools-deps (21)
- # xtdb (20)
@ordnungswidrig just makess it tricky to create a series of intervals where the interval switches at one point on the same date
The problem is that were lacking the notion of "rounding" with timestamps. It's clear to everybody that the integer 2 "corresponds" with the rational interval [1.0...2.0)
We have a date notions of the interval as e.g. "2020-05-03" but all libraries I know internally represent this to the revision of the nanosecond.
It's like using floats to represent integer values. Prepare for some weird confusing stuff to happen :-)
@ordnungswidrig yeah, I think you are right there. I wonder if there is other prior art like the relational algrebra that they borrow that makes this behaviour a bit more principled. I think my worry is that any work around I do could change in a later version if it is undefined
Something like āfloating point datesā. One property of FP is the change of absolute precision.
But dates are weird because they are a weird mix of absolute values, intervals, the use of arbitrary, mixed and changing units, UI features which change over time, non-unique representations (DST change) and bad compatibitlity with the binary and decimal system.
java.time
is generally pretty good at this stuff though, since they actually recognize that a date is different from a "year-month", is different from a timestamp, etc. for instance LocalDate
is really just a year+month+day fields, no unix timestamp in sight https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/classes/java/time/LocalDate.java#L169-L177
the problem to me in the above @otfrom is that you're asking for an interval between dates, but you're getting an interval between date-times
(import '(java.time LocalDate Period))
(Period/between
(LocalDate/of 2020 01 01)
(LocalDate/of 2020 01 02))
;; => #object[java.time.Period 0x35860e12 "P1D"]
I guess interval is a tick-specific thing, java.time has Period (in days) and Duration (in nanoseconds)@plexus java.time has some good stuff in it
Although now Iām confused that LocalDate
doesnāt implement a single Interface which is parametrized over a dozen generics š
Thatās weird public boolean isSupported(TemporalField field)
that sounds where you would use types for.
OMG ā* Defend against malicious streams.ā. I had enough java for today
interval is an implementation of this: https://en.wikipedia.org/wiki/Allen%27s_interval_algebra
looks like my real issue is whether or not this behaviour is correct:
(t/bounds (t/today))
#:tick{:beginning #time/date-time "2020-07-09T00:00", :end #time/date-time "2020-07-10T00:00"}
(I'll still have the issue as my end of episode 1 and start of episode 2 are on the same day)
if only there was some way I could write some unit tests to make sure the behaviour stays the same as I change the code... š
right... I think this is the core of my issue;
(t/end (t/date "2020-07-09"))
#time/date-time "2020-07-10T00:00"
so where does the minute between 2020-07-09T23:59 and 2020-07-10T00:00 go (or second or nanosecond)? seems to me to make sense that (= (end-of today) (start-of tomorrow))
, it's the same point on the timeline
yeah, I think it is just a conversion problem with where you draw the bounds when you only have something less precise
should an interval that is {:start 2020-01-02 :end 2020-01-03} and {:start 2020-01-03 :end 2002-01-05} be considered as overlapping or meeting on 3 January?
yeah, the problem is the library is doing the conversion for me rather than comparing the dates
if you're talking about dates, and your intervals are ending exclusive, then those two would meet but not overlap
(t/relation
#:tick{:beginning #time/date-time "2020-07-09T00:00", :end #time/date-time "2020-07-10T00:00"}
#:tick{:beginning #time/date-time "2020-07-10T00:00", :end #time/date-time "2020-07-11T00:00"})
:meets
so when the date times are equal, then the relation meets, but if only dates are supplied and equal then they overlap
so I have to pre-process my dates into suitable interval friendly date times before supplying them to t/relation
which is fine as long as the conversion from date to date time bounded interval is stable behaviour
The weird things is that the answer to do these intervals overlap is quite obvious {:beginning 10 :end 15} {:beginning 15 :end 20}
.. it depends! On wether the ends are open or closed.
I think the behaviour of the date time example shows how it works: https://clojurians.slack.com/archives/CBJ5CGE0G/p1594287276141400
I think I'd down to my issue being how dates are converted to intervals, and I think I have a solution to it now
so, I've gone with this in my code and it gives me the :meets behaviour I want when creating relations
(defn episode-interval [{:keys [report-date ceased] :as rec}]
(if ceased
(assoc rec
:episode-interval
(t/new-interval (t/at report-date "13:00") (t/at ceased "13:00")))
rec))
the common code for this is going here: https://github.com/MastodonC/witan.cic.driver
This is intereting https://www.w3.org/TR/owl-time/
is the Web Ontology Language widely used? I almost never come across it for my work But that might just be because I'm boxed into a niche
will probably have some RDF impact (as they are often the same people) and thus impact on Rich who is a fan of RDF (see schema, datomic, etc)
so it looks like you can't create a LocalDateTime from a LocalDate w/o supplying a time explicitly https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html#of-java.time.LocalDate-java.time.LocalTime-
Iām wondering how to pass global objects to the templatesā¦Ā things that shall be rendered on all sites.
I have a few ideas, like using thread-locals or soā¦ or ^:dynamic
(itās technically also a thread local, right?), or injecting some payload into the request object and pass that to the templates, but somehow it doesnāt feel rightā¦
> Iām wondering how to pass global objects to the templatesā¦Ā things that shall be rendered on all sites.
Sorry, don't know what you mean. Since it's just data:tm:, you can have a page
function to return it. And that function can call your own fixed-header
or fixed-footer
functions.
What am I missing here?
hey, I want to carry some meta data to global elements in all templates; e.g. currently authenticated user in the header of a page. I was just wondering whether thereās a idiomatic way of doing it
Sorry, still don't get it. Aren't the informationen needed to render the page all available in the request or session? > maybe I should just look for other projects at github and see how they do it Caution: Some things you'll see will be spooky. š»
no itās not available per-se, hence the question how to do it the best š
(defn outer-layout [] (header (user-session-info) (dynamic-navigation)))
(defn inner-layout [] (outer-layout))
(defn actual-page [payload] (inner-layout payload))
How do I get the data for user-sessio-info
when my handlers just call the actual-page
I should maybe just reverse my call, so instead of calling actual-page
directly, I could call the outer-layout
pass the data from handlers direct to it and also pass the inner desired page
I think I just talk confusing things right now; I should rather just try something out š
I typically use a global reagent atom to hold state. Templates can reach out here and self-service what they need.
just pass the data to where you need it. These days I like to have a single view-data
map that gets passed both to the page's view functions as well as to the layout, just stick whatever either needs in there. :title
, :current-user
, :blog-posts
etc.
start with that and then add whatever sugar you like. we have some helpers that allow passing some values from the view to the layout based on metadata, which is nice for something like this:
(defn blog-post-html [{:keys [blog-post]}]
^{:title "Blog posts"}
[:article ...])
@ordnungswidrig youāre likely talking about frontend, no?
aaah, sorry I had assumed reagent. But same for backend š
I typically pass-down the information often having a first ācontextā argument which is a map with all kind of information you want to have everywhere, e.g. authentication information or resource handles.
Namespaced keys help to keep things apart:
{:auth/user "synthomatc" :res/db-conn <DBConnection> :http/request raw-http-request}
etc. and pass the more local parameters as separate keys.
I also used the āall parameters and context in a single mapā approach which is nice for descructuring.
(defn template [{:keys [:res/db-conn :auth/user :posts :highlighted-post-id}])