Fix datemark calculation not taking into account local time

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-03-05 13:17:11 +01:00
parent b1331378d5
commit 382eeaa696
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
(ns status-im.utils.datetime (ns status-im.utils.datetime
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[cljs-time.core :as t :refer [date-time plus days hours before?]] [cljs-time.core :as t :refer [date-time plus minus days hours before?]]
[cljs-time.coerce :refer [from-long to-long from-date]] [cljs-time.coerce :refer [from-long to-long from-date]]
[cljs-time.format :refer [formatters [cljs-time.format :refer [formatters
formatter formatter
@ -80,7 +80,7 @@
(defn- to-str [ms old-fmt-fn yesterday-fmt-fn today-fmt-fn] (defn- to-str [ms old-fmt-fn yesterday-fmt-fn today-fmt-fn]
(let [date (from-long ms) (let [date (from-long ms)
local (plus date time-zone-offset) ; this is wrong, it uses the current timezone offset, regardless of DST local (plus date time-zone-offset) ; this is wrong, it uses the current timezone offset, regardless of DST
today (t/today-at-midnight) today (minus (t/today-at-midnight) time-zone-offset)
yesterday (plus today (days -1))] yesterday (plus today (days -1))]
(cond (cond
(before? date yesterday) (old-fmt-fn local) (before? date yesterday) (old-fmt-fn local)