Skip to content

Broken equality comparisons #116

@hokomo

Description

@hokomo

It seems like equality is implemented using clojure.core/= [1, 2, 3], resulting in the following surprising output in 1.4.3:

(require '[java-time :as jt])

> (let [zdt (jt/zoned-date-time)]
    (jt/= (jt/with-zone-same-instant zdt "UTC")
          (jt/with-zone-same-instant zdt "Z")))
false

For comparison, here's java.time and juxt/tick:

> (let [zdt (java.time.ZonedDateTime/now)]
    (.isEqual (.withZoneSameInstant zdt (java.time.ZoneId/of "UTC"))
              (.withZoneSameInstant zdt (java.time.ZoneId/of "Z"))))
true
(require '[tick.core :as tick])

> (let [zdt (tick/zoned-date-time)]
    (tick/= (tick/in zdt "UTC")
            (tick/in zdt "Z")))
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions