Phase 1: Refactor DateParser structure

- Create DateParser struct with configurable base time and week start
- Add placeholder methods for new parsing features
- Implement time-of-day parsing foundation (splitDateTime, parseTimeOfDay)
- Maintain backward compatibility with existing ParseDate() function
- Update tests to use new DateParser API
- All 33 existing tests passing
This commit is contained in:
2026-01-05 09:54:58 +01:00
parent a68d701d14
commit b37e2dfc39
3 changed files with 256 additions and 19 deletions
+4 -2
View File
@@ -199,7 +199,8 @@ func TestParseDateWeekday(t *testing.T) {
func TestNextWeekday(t *testing.T) {
// Test case: Thursday -> next Sunday should be this Sunday
thursday := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC) // Jan 1, 2026 is a Thursday
nextSun := nextWeekday(thursday, time.Sunday)
parser := NewDateParser(thursday, time.Monday)
nextSun := parser.nextWeekday(time.Sunday)
if nextSun.Weekday() != time.Sunday {
t.Error("Should return Sunday")
@@ -214,7 +215,8 @@ func TestNextWeekday(t *testing.T) {
// Test case: Sunday -> next Sunday should be 7 days later
sunday := time.Date(2026, 1, 4, 0, 0, 0, 0, time.UTC) // Jan 4, 2026 is a Sunday
nextSun2 := nextWeekday(sunday, time.Sunday)
parser2 := NewDateParser(sunday, time.Monday)
nextSun2 := parser2.nextWeekday(time.Sunday)
expectedDays = 7
actualDays = int(nextSun2.Sub(sunday).Hours() / 24)