This commit is contained in:
2026-03-26 03:54:12 +07:00
parent 0a6294a62f
commit a975baffa7
9 changed files with 93 additions and 3 deletions
+16 -1
View File
@@ -6,6 +6,7 @@ import (
"log"
"os"
"pinned_message/internal/models"
"time"
)
type ScheduleStorage struct {
@@ -42,5 +43,19 @@ func (s *ScheduleStorage) GetSchedule() ([]*models.Day, error) {
if err := json.Unmarshal(data, &days); err != nil {
return nil, err
}
return days, nil
filterDays := make([]*models.Day, 0, len(days))
for _, day := range days {
if isBeforeToday(day.Date) {
continue
}
filterDays = append(filterDays, day)
}
return filterDays, nil
}
func isBeforeToday(targetDate time.Time) bool {
now := time.Now()
todayMidnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
targetMidnight := time.Date(targetDate.Year(), targetDate.Month(), targetDate.Day(), 0, 0, 0, 0, targetDate.Location())
return targetMidnight.Before(todayMidnight)
}