Fix: timezone offset for today was missing

This commit is contained in:
Eric Dvorsak 2017-09-06 02:34:20 +02:00 committed by Roman Volosovskyi
parent 36d1568a76
commit de9905a14e
1 changed files with 6 additions and 9 deletions

View File

@ -25,16 +25,13 @@
([ms]
(to-short-str ms #(unparse (formatters :hour-minute) %)))
([ms today-format-fn]
(let [date (from-long ms)
local (plus date time-zone-offset)
today-date (t/today)
today (date-time (t/year today-date)
(t/month today-date)
(t/day today-date))
yesterday (plus today (days -1))]
(let [date (from-long ms)
local (plus date time-zone-offset)
today (t/today-at-midnight)
yesterday (plus today (days -1))]
(cond
(before? local yesterday) (unparse (formatter "dd MMM hh:mm") local)
(before? local today) (label :t/datetime-yesterday)
(before? date yesterday) (unparse (formatter "dd MMM hh:mm") local)
(before? date today) (label :t/datetime-yesterday)
:else (today-format-fn local)))))
(defn day-relative [ms]