Files
apocapoc-api/internal/shared/utils/date_utils.go
T
david 34ea1f718e Implement Application Layer with TDD
- Add date utilities for habit scheduling logic
- Implement CreateHabitHandler with full validation
- Implement GetTodaysHabitsHandler with carry-over support
- Implement MarkHabitHandler for completing habits
- All components developed following TDD methodology
- Complete test coverage for commands and queries
2025-11-25 23:54:49 +01:00

32 lines
524 B
Go

package utils
import "time"
func ShouldAppearToday(
frequency string,
specificDays []int,
specificDates []int,
targetDate time.Time,
) bool {
switch frequency {
case "DAILY":
return true
case "WEEKLY":
weekday := int(targetDate.Weekday())
return contains(specificDays, weekday)
case "MONTHLY":
day := targetDate.Day()
return contains(specificDates, day)
}
return false
}
func contains(slice []int, val int) bool {
for _, item := range slice {
if item == val {
return true
}
}
return false
}