From 17ee522779ea43db5af0838f854584b9a64f3085 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Sat, 4 Jan 2025 00:52:39 +0800 Subject: [PATCH] fix: date label --- .../frontend/components/property/value.cljs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index b97992316a..286b06edb7 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -382,19 +382,20 @@ (defn- human-date-label [date] - (let [today (t/today)] + (let [today (t/today) + today-y (t/year today) + today-m (t/month today) + today-d (t/day today) + same-day? (fn [date] + (and (= today-y (t/year date)) (= today-m (t/month date)) (= today-d (t/day date))))] (cond - (and (or (t/after? date today) - (t/equal? date today)) - (t/before? date (t/plus today (t/days 1)))) + (same-day? date) "Today" - (and (or (t/equal? date (t/plus today (t/days 1))) - (t/after? date (t/plus today (t/days 1)))) - (t/before? date (t/plus today (t/days 2)))) + (let [tomorrow (t/minus date (t/days 1))] + (same-day? tomorrow)) "Tomorrow" - (and (or (t/equal? date (t/minus today (t/days 1))) - (t/after? date (t/minus today (t/days 1)))) - (t/before? date today)) + (let [yesterday (t/plus date (t/days 1))] + (same-day? yesterday)) "Yesterday" :else nil)))