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
This commit is contained in:
2025-11-25 23:54:49 +01:00
parent 0977d3a58b
commit 34ea1f718e
8 changed files with 1002 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
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
}