diff --git a/api.go b/api.go index 31b1b3c..839a8a7 100644 --- a/api.go +++ b/api.go @@ -297,32 +297,32 @@ func (s *Server) handleRecordings(w http.ResponseWriter, r *http.Request) { // Determine date range from preset or custom range. var fromTime, toTime time.Time now := time.Now() + todayEnd := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, now.Location()) switch preset { case "today": fromTime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) - toTime = now + toTime = todayEnd case "yesterday": yesterday := now.AddDate(0, 0, -1) fromTime = time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, now.Location()) toTime = time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, now.Location()) case "week": fromTime = now.AddDate(0, 0, -7) - toTime = now + toTime = todayEnd default: - // Parse custom date range. if fromStr != "" { - fromTime, _ = time.Parse("2006-01-02", fromStr) + fromTime, _ = time.ParseInLocation("2006-01-02", fromStr, now.Location()) } if toStr != "" { - toTime, _ = time.Parse("2006-01-02", toStr) - toTime = toTime.Add(24*time.Hour - time.Second) // end of day + toTime, _ = time.ParseInLocation("2006-01-02", toStr, now.Location()) + toTime = toTime.Add(24*time.Hour - time.Second) } if fromStr == "" { - fromTime = now.AddDate(0, 0, -1) // default: last 24h + fromTime = now.AddDate(0, 0, -1) } if toStr == "" { - toTime = now + toTime = todayEnd } } @@ -371,7 +371,7 @@ func (s *Server) handleRecordings(w http.ResponseWriter, r *http.Request) { timeStr := strings.TrimPrefix(name, "rec_") timeStr = strings.TrimSuffix(timeStr, ".mp4") timeStr = strings.TrimSuffix(timeStr, ".part") - if t, err := time.Parse("2006-01-02-15-04-05", timeStr); err == nil { + if t, err := time.ParseInLocation("2006-01-02-15-04-05", timeStr, now.Location()); err == nil { clip.Time = t.Format("15:04") if !fromTime.IsZero() && t.Before(fromTime) { continue