Skip to content

fix(timeutil): accept RFC3339 timestamps in since/until args#62

Merged
ysyneu merged 1 commit into
mainfrom
fix/timeutil-rfc3339
May 31, 2026
Merged

fix(timeutil): accept RFC3339 timestamps in since/until args#62
ysyneu merged 1 commit into
mainfrom
fix/timeutil-rfc3339

Conversation

@ysyneu
Copy link
Copy Markdown
Collaborator

@ysyneu ysyneu commented May 31, 2026

Problem

Same root cause as flashduty-cli#25, in the MCP server's copy of internal/timeutil.

The flashduty SDK renders timestamps as RFC3339 (e.g. 2026-05-29T00:00:00+08:00), so an LLM caller copies those values out of one tool's output and back into the since/until args of the next. timeutil.Parse only accepted duration / 2006-01-02 / 2006-01-02 15:04:05 / unix — not the RFC3339 we emit — so it failed with unable to parse time "2026-05-29T00:00:00+08:00".

Fix

Parse now tries RFC3339Nano/RFC3339 (honoring the embedded offset or Z) before the local-zone layouts, and also accepts the T-separated datetime without a timezone. ParseAny (the MCP tool-arg entry point) delegates strings to Parse, so all string-valued time args gain the same support. Output is unchanged; this only widens accepted input to the shape we already emit.

Verification

Unit tests cover +08:00 offset, Z, fractional-second RFC3339Nano, and bare-T no-tz; suite green, full go build ./... clean.

The flashduty SDK renders timestamps as RFC3339 (e.g.
"2026-05-29T00:00:00+08:00"), so an LLM caller naturally copies those
values straight out of one tool's output back into the since/until args of
the next. timeutil.Parse only understood duration / "2006-01-02" /
"2006-01-02 15:04:05" / unix, so it failed with
`unable to parse time "2026-05-29T00:00:00+08:00"`.

Parse now tries RFC3339/RFC3339Nano (honoring the embedded offset or "Z")
before the local-zone layouts, and also accepts the "T"-separated datetime
without a timezone. ParseAny delegates strings to Parse, so MCP tool args
gain the same support. Output is unchanged; this only widens accepted
input to include the exact shape we already emit.
@ysyneu ysyneu merged commit 85c6a89 into main May 31, 2026
13 checks passed
@ysyneu ysyneu deleted the fix/timeutil-rfc3339 branch May 31, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant