diff --git a/internal/commands/worklog.go b/internal/commands/worklog.go index fa51328..a608fc6 100644 --- a/internal/commands/worklog.go +++ b/internal/commands/worklog.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "time" "git.hangman-lab.top/zhi/HarborForge.Cli/internal/output" ) @@ -35,9 +36,18 @@ func RunWorklogAdd(taskCode string, hours float64, desc, date, tokenFlag string) if desc != "" { payload["description"] = desc } + // logged_date is a REQUIRED datetime on the backend. Default to now; if + // the operator passed --date , anchor it to start-of-day so a + // bare date still parses as a datetime. + loggedDate := time.Now().UTC().Format(time.RFC3339) if date != "" { - payload["logged_date"] = date + if len(date) == 10 { // bare YYYY-MM-DD + loggedDate = date + "T00:00:00Z" + } else { + loggedDate = date + } } + payload["logged_date"] = loggedDate body, err := json.Marshal(payload) if err != nil {