Fix DueDate parsing to support Checkvist API slash format

The Checkvist API returns due dates in slash format (2026/01/15),
but parseDueDate() only supported ISO format with dashes.

- Extend parseDueDate() to try both formats (slashes and dashes)
- Add test case for Checkvist API format parsing
- Fix TestTaskBuilder to use existing DueTomorrow constant

Closes checkvist-api-otm
This commit is contained in:
Oliver Jakoubek 2026-01-15 09:29:20 +01:00
commit 8c9f888927
4 changed files with 49 additions and 6 deletions

View file

@ -376,6 +376,11 @@ func TestDueDate_Parsing(t *testing.T) {
dueRaw: "2026-01-20",
expected: timePtr(time.Date(2026, 1, 20, 0, 0, 0, 0, time.UTC)),
},
{
name: "Checkvist API format (slashes)",
dueRaw: "2026/01/20",
expected: timePtr(time.Date(2026, 1, 20, 0, 0, 0, 0, time.UTC)),
},
{
name: "empty string",
dueRaw: "",
@ -413,7 +418,7 @@ func TestTaskBuilder(t *testing.T) {
builder := NewTask("Test content").
WithParent(50).
WithPosition(3).
WithDueDate(DueNextWeek).
WithDueDate(DueTomorrow).
WithPriority(2).
WithTags("work", "urgent")