Fix date parsing for Checkvist API format

Add custom APITime type with UnmarshalJSON to handle the non-standard
date format returned by the Checkvist API ("2026/01/14 16:07:31 +0000")
instead of the expected RFC3339 format.

Changes:
- Add APITime type with custom JSON marshaling/unmarshaling in models.go
- Replace time.Time with APITime for UpdatedAt/CreatedAt fields in
  Checklist, Task, and Note structs
- Add NewAPITime constructor for convenience
- Update test fixtures to use real API date format
- Add comprehensive unit tests for APITime in models_test.go

Fixes: checkvist-api-4qn
This commit is contained in:
Oliver Jakoubek 2026-01-14 18:10:02 +01:00
commit e4862b8e9b
12 changed files with 241 additions and 30 deletions

View file

@ -71,8 +71,8 @@ func TestNotes_Create(t *testing.T) {
ID: 600,
TaskID: 101,
Comment: req.Comment,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
CreatedAt: NewAPITime(time.Now()),
UpdatedAt: NewAPITime(time.Now()),
}
json.NewEncoder(w).Encode(response)
default:
@ -119,7 +119,7 @@ func TestNotes_Update(t *testing.T) {
ID: 501,
TaskID: 101,
Comment: req.Comment,
UpdatedAt: time.Now(),
UpdatedAt: NewAPITime(time.Now()),
}
json.NewEncoder(w).Encode(response)
default: