1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: make intervals robust to daylight saving time shift

This commit is contained in:
Ferdinand Mütsch
2022-10-31 23:24:25 +01:00
parent c8ea1a503f
commit 9586dbf781
3 changed files with 677 additions and 630 deletions

View File

@@ -86,7 +86,7 @@ func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
return
}
minStart := rangeTo.Add(-24 * time.Hour * time.Duration(requestedUser.ShareDataMaxDays))
minStart := rangeTo.AddDate(0, 0, -requestedUser.ShareDataMaxDays)
if (authorizedUser == nil || requestedUser.ID != authorizedUser.ID) &&
rangeFrom.Before(minStart) && requestedUser.ShareDataMaxDays >= 0 {
w.WriteHeader(http.StatusForbidden)