time.clj icon indicating copy to clipboard operation
time.clj copied to clipboard

date object behaves confusingly when printed

Open saitouena opened this issue 5 years ago • 0 comments

My environment:

  • Clojure 1.10.1
  • openjdk version "1.8.0_222" OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10) OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
(def zero-zone (t/time-zone "GMT+00:00"))

(def plus8-zone (t/time-zone "GMT+08:00"))

(t/date d :time-zone zero-zone)
=> #inst"2019-11-25T05:15:28.738-00:00"
(t/date d :time-zone plus8-zone)
=> #inst"2019-11-25T05:15:28.738-00:00"
;; looks same

(-> d
    (t/date :time-zone zero-zone)
    (t/format "yyyyMMdd HH:mm:ss"))
=> "20191125 05:15:28"
(-> d
    (t/date :time-zone plus8-zone)
    (t/format "yyyyMMdd HH:mm:ss"))
=> "20191125 13:15:28"
;; format works correct

I haven't read the codes, but I think wrapping date object and implementing toString can be a workaround.

saitouena avatar Nov 25 '19 05:11 saitouena