Skip to content

Fix tick.core/micros for negative durations (#208)#209

Merged
henryw374 merged 4 commits intojuxt:masterfrom
yuhan0:fix-208
May 5, 2026
Merged

Fix tick.core/micros for negative durations (#208)#209
henryw374 merged 4 commits intojuxt:masterfrom
yuhan0:fix-208

Conversation

@yuhan0
Copy link
Copy Markdown
Contributor

@yuhan0 yuhan0 commented May 2, 2026

Closes #208.

(Side note: I had an unrelated test failure here

(is (= (t/date "2018-01-11")
(t/date (t/instant 1515691416624))))

which seems to be a faullty test? The t/date conversion depends on ambient clock / timezone, which in my case happened to return #time/date "2018-01-12")

@henryw374
Copy link
Copy Markdown
Collaborator

couple of failing tests there.

... and yes, that other test could have a t/with-clock around it to make it work

@yuhan0
Copy link
Copy Markdown
Contributor Author

yuhan0 commented May 5, 2026

oops, I didn't think to run cljs tests locally, and attempting to run make test-cljs-shadow failed with

#error {
 :cause Exec failed, error: 2 (No such file or directory)
 :via
 [{:type java.io.IOException
   :message Cannot run program "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome": Exec failed, error: 2 (No such file or directory)

(I use ungoogled-chromium 😬)

But in any case looking at the CI test failure it seems to be an underlying inconsistency between js-joda and java-time? The failing tests are

    (is (= -1 (t/millis  (t/of-nanos  -1999999))))
    (is (= -1 (t/millis  (t/of-micros -1001))))

where clj returns -1, cljs returns -2.

I believe that means the following also returns different results depending on platform? (I don't have a cljs dev setup at hand to test with)

(cljc.java-time.duration/to-millis (cljc.java-time.duration/of-nanos -1000001))

Would you rather I fix it by wrapping in a reader conditional #?(:clj -1 :cljs -2) or remove the block of tests entirely (punting semantic quirks to upstream libs)

@henryw374
Copy link
Copy Markdown
Collaborator

hmm. tricky. fix it by wrapping in a reader conditional #?(:clj -1 :cljs -2) I think.

please just add a comment that this is discrepancy from underlying lib

@yuhan0
Copy link
Copy Markdown
Contributor Author

yuhan0 commented May 5, 2026

ok pushed along with the with-clock fix, let me know if you prefer the commits squashed

@henryw374 henryw374 merged commit 6f3d39c into juxt:master May 5, 2026
1 check passed
@henryw374
Copy link
Copy Markdown
Collaborator

looks good. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t/micros returns wrong result for negative durations

2 participants