diff options
author | Griffin Smith <grfn@gws.fyi> | 2022-05-01T21·35-0400 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-05-14T15·59+0000 |
commit | 13a9de649391dd0da98a050c0130f000b97ed3af (patch) | |
tree | 1785eb461c53887a09a723abf901bd371fd578f7 /users | |
parent | b5105034791a2af1bd9370aeb0aa741300e0641b (diff) |
fix(grfn/bbbg): Still display today's event past midnight utc r/4071
Change-Id: Ieb448f3998da52206a4ee89779678747514b2a82 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5511 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: grfn <grfn@gws.fyi>
Diffstat (limited to 'users')
-rw-r--r-- | users/grfn/bbbg/src/bbbg/db/event.clj | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/users/grfn/bbbg/src/bbbg/db/event.clj b/users/grfn/bbbg/src/bbbg/db/event.clj index 5e93691dfa14..1b5a4e11ecd7 100644 --- a/users/grfn/bbbg/src/bbbg/db/event.clj +++ b/users/grfn/bbbg/src/bbbg/db/event.clj @@ -6,7 +6,7 @@ [bbbg.util.sql :refer [count-where]] [honeysql.helpers :refer [merge-group-by merge-left-join merge-select merge-where]] - [java-time :refer [local-date]])) + [java-time :refer [local-date local-date-time local-time]])) (defn create! [db event] (db/insert! db :event (select-keys event [::event/date]))) @@ -29,8 +29,31 @@ ([db day] (db/list db (on-day day)))) + +(def end-of-day-hour + ;; 7am utc = 3am nyc + 7) + +(defn current-day + ([] (current-day (local-date-time))) + ([dt] + (if (<= 0 + (.getHour (local-time dt)) + end-of-day-hour) + (java-time/minus + (local-date dt) + (java-time/days 1)) + (local-date dt)))) + +(comment + (current-day + (local-date-time + 2022 5 1 + 1 13 0)) + ) + (defn today - ([] (on-day (local-date))) + ([] (on-day (current-day))) ([db] (db/list db (today)))) (defn upcoming |