Problem
Current date parsing in StudyPlan is fragile. It struggles with ambiguous formats (e.g., 03/04/2026), natural language phrases (end of next week, first Monday of next month), and invalid inputs. This leads to incorrect deadlines, failed calendar exports, and inconsistent user experiences.
Proposed Improvement
Introduce a centralized robust date parser utility that:
Normalizes ambiguous formats with a clear interpretation strategy.
Supports natural language expressions using libraries like chrono-node or custom logic.
Validates all parsed dates before saving to the database.
Provides fallback behavior (e.g., prompt user confirmation) when parsing fails.
Includes unit tests covering edge cases and invalid inputs.
Why improvement is needed
Prevents scheduling errors and misinterpreted deadlines.
Improves reliability of AI fallback when external APIs fail.
Enhances user trust in StudyPlan’s calendar and reminder features.
Future-proofs the system for additional date-related features.
Expected Result
Consistent and accurate date parsing across all modules.
Clear error handling for unsupported or invalid inputs.
Seamless integration with calendar export and task scheduling.
Higher test coverage ensuring long-term stability.
Alternatives Considered
Continue using regex-based parsing (too brittle and error-prone).
Rely solely on external AI parsing (not reliable when API fails).
Manually prompt users for corrections (adds friction, not scalable).
Additional Context
This PR builds on the recent fix excluding invalid dates during ICS export but goes further by addressing robustness and natural language support. It complements issue #1173, which highlights the need for improved NLP fallback parsing.
Problem
Current date parsing in StudyPlan is fragile. It struggles with ambiguous formats (e.g., 03/04/2026), natural language phrases (end of next week, first Monday of next month), and invalid inputs. This leads to incorrect deadlines, failed calendar exports, and inconsistent user experiences.
Proposed Improvement
Introduce a centralized robust date parser utility that:
Normalizes ambiguous formats with a clear interpretation strategy.
Supports natural language expressions using libraries like chrono-node or custom logic.
Validates all parsed dates before saving to the database.
Provides fallback behavior (e.g., prompt user confirmation) when parsing fails.
Includes unit tests covering edge cases and invalid inputs.
Why improvement is needed
Prevents scheduling errors and misinterpreted deadlines.
Improves reliability of AI fallback when external APIs fail.
Enhances user trust in StudyPlan’s calendar and reminder features.
Future-proofs the system for additional date-related features.
Expected Result
Consistent and accurate date parsing across all modules.
Clear error handling for unsupported or invalid inputs.
Seamless integration with calendar export and task scheduling.
Higher test coverage ensuring long-term stability.
Alternatives Considered
Continue using regex-based parsing (too brittle and error-prone).
Rely solely on external AI parsing (not reliable when API fails).
Manually prompt users for corrections (adds friction, not scalable).
Additional Context
This PR builds on the recent fix excluding invalid dates during ICS export but goes further by addressing robustness and natural language support. It complements issue #1173, which highlights the need for improved NLP fallback parsing.