Skip to content

fix(calendar): interpret date-only --to values as end of day#204

Closed
mjaskolski wants to merge 2 commits intoopenclaw:mainfrom
mjaskolski:fix/date-only-timezone-155
Closed

fix(calendar): interpret date-only --to values as end of day#204
mjaskolski wants to merge 2 commits intoopenclaw:mainfrom
mjaskolski:fix/date-only-timezone-155

Conversation

@mjaskolski
Copy link
Copy Markdown
Contributor

Summary

When --to is given a date-only value like 2026-02-02 or a relative expression like tomorrow, it was parsed as start of day (00:00:00), creating a zero-length query window when paired with the same --from date. This meant --from 2026-02-02 --to 2026-02-02 returned no events.

Fix

Added parseTimeExprEndOfDay() which wraps parseTimeExpr() and adjusts date-only/relative results to end of day (23:59:59.999). The --to flag now uses this function.

This matches the behavior of --today/--tomorrow convenience flags which already used endOfDay() correctly.

What's preserved

  • Full RFC3339 timestamps with explicit times are unchanged
  • --from still resolves to start of day (correct for range starts)
  • All existing tests pass, new tests added for the EndOfDay variant

Fixes #155

When --to is given a date-only value like '2026-02-02' or a relative
expression like 'tomorrow', parse it as end of day (23:59:59.999)
instead of start of day (00:00:00). This fixes the issue where
'--from 2026-02-02 --to 2026-02-02' returns no events because both
values resolve to the same midnight timestamp, creating a zero-length
query window.

The --today/--tomorrow convenience flags already handled this correctly
by using endOfDay() for the 'to' bound. This change applies the same
logic to date-only and relative --to values parsed via parseTimeExpr.

Full RFC3339 timestamps with explicit times are preserved as-is.

Fixes openclaw#155
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37a8e5ead4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/time_helpers.go Outdated
Comment on lines +161 to +164
// If the result is exactly midnight (start of day), it was likely a date-only
// or relative day expression — adjust to end of day.
if t.Hour() == 0 && t.Minute() == 0 && t.Second() == 0 && t.Nanosecond() == 0 {
return endOfDay(t), nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit midnight timestamps for --to

The new end-of-day adjustment triggers whenever the parsed time is exactly midnight, which also includes explicit RFC3339 timestamps like 2025-01-05T00:00:00Z. That means a user who intentionally specifies an exact midnight end time will silently get 23:59:59.999 instead, expanding the query window beyond what they asked for. This contradicts the stated intent to preserve full RFC3339 timestamps and will mis-handle any --to values that are intentionally midnight. Consider gating the adjustment on the original expression format (e.g., only date-only/relative inputs) instead of the parsed time value alone.

Useful? React with 👍 / 👎.

Previously parseTimeExprEndOfDay() checked if the parsed time was exactly
midnight to decide whether to adjust to end-of-day. This incorrectly
caught explicit RFC3339 timestamps like --to 2025-01-05T00:00:00Z where
the user intentionally specified midnight.

Now the function checks the raw input string format instead:
- Date-only (YYYY-MM-DD), relative keywords (today/tomorrow/yesterday),
  and weekday names → adjusted to end of day (23:59:59.999999999)
- Full timestamps (RFC3339, ISO8601, local datetime with T) → preserved as-is

Addresses Codex review feedback on PR openclaw#204.
@steipete steipete self-assigned this Feb 14, 2026
steipete added a commit that referenced this pull request Feb 14, 2026
Land #204 and preserve point-in-time semantics for --to now.

Co-authored-by: Michal Jaskolski <mjaskolski@users.noreply.github.com>
@steipete
Copy link
Copy Markdown
Collaborator

Landed on main in 16fdf07 with the requested follow-up: date-only/relative --to is end-of-day inclusive, and --to now stays exact point-in-time.

Thanks @mjaskolski for the PR.

@steipete
Copy link
Copy Markdown
Collaborator

Closing as landed via commit 16fdf07 on main.

@steipete steipete closed this Feb 14, 2026
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
Land openclaw#204 and preserve point-in-time semantics for --to now.

Co-authored-by: Michal Jaskolski <mjaskolski@users.noreply.github.com>
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.

Date-only --from/--to flags don't respect local timezone

2 participants