Fix DueDate format: remove caret prefix for API compatibility
The Checkvist API expects due_date values without the caret (^) prefix. The ^ prefix is only used in task content smart syntax, not in API parameters. - Remove ^ prefix from DueToday and DueTomorrow constants - Remove unused DueASAP and DueMonday constants - Update DueAt() and DueInDays() to not add ^ prefix - Update tests to expect new format Closes checkvist-api-4pz
This commit is contained in:
parent
8c9f888927
commit
ff67719aed
4 changed files with 13 additions and 15 deletions
18
models.go
18
models.go
|
|
@ -175,25 +175,21 @@ type DueDate struct {
|
|||
value string
|
||||
}
|
||||
|
||||
// Common due date constants using Checkvist's smart syntax.
|
||||
// Common due date constants for the Checkvist API.
|
||||
var (
|
||||
// DueToday sets the due date to today.
|
||||
DueToday = DueDate{value: "^Today"}
|
||||
DueToday = DueDate{value: "Today"}
|
||||
// DueTomorrow sets the due date to tomorrow.
|
||||
DueTomorrow = DueDate{value: "^Tomorrow"}
|
||||
// DueASAP sets the due date to ASAP.
|
||||
DueASAP = DueDate{value: "^ASAP"}
|
||||
// DueMonday sets the due date to next Monday.
|
||||
DueMonday = DueDate{value: "^Monday"}
|
||||
DueTomorrow = DueDate{value: "Tomorrow"}
|
||||
)
|
||||
|
||||
// DueAt creates a DueDate from a Go time.Time value.
|
||||
func DueAt(t time.Time) DueDate {
|
||||
return DueDate{value: "^" + t.Format("2006-01-02")}
|
||||
return DueDate{value: t.Format("2006-01-02")}
|
||||
}
|
||||
|
||||
// DueString creates a DueDate from a raw smart syntax string.
|
||||
// The string should use Checkvist's smart syntax (e.g., "^2026-02-01", "^friday", "^next week").
|
||||
// DueString creates a DueDate from a raw string.
|
||||
// Use this for custom date formats (e.g., "2026-02-01", "friday", "next week").
|
||||
func DueString(s string) DueDate {
|
||||
return DueDate{value: s}
|
||||
}
|
||||
|
|
@ -201,7 +197,7 @@ func DueString(s string) DueDate {
|
|||
// DueInDays creates a DueDate for n days from now.
|
||||
func DueInDays(n int) DueDate {
|
||||
t := time.Now().AddDate(0, 0, n)
|
||||
return DueDate{value: "^" + t.Format("2006-01-02")}
|
||||
return DueDate{value: t.Format("2006-01-02")}
|
||||
}
|
||||
|
||||
// String returns the smart syntax string for the due date.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue