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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user