Skip to content

fix: anchor git date filters to local midnight#2

Merged
ashishxcode merged 1 commit into
mainfrom
fix/date-range-midnight-anchor
May 25, 2026
Merged

fix: anchor git date filters to local midnight#2
ashishxcode merged 1 commit into
mainfrom
fix/date-range-midnight-anchor

Conversation

@ashishxcode
Copy link
Copy Markdown
Owner

Problem

Selecting Yesterday in the range picker showed commits dated today, and Today reported "nothing found" for commits that clearly existed.

Root cause: internal/collect/git.go passed bare YYYY-MM-DD dates to git log --since/--until. Git parses bare dates with approxidate, which fills the missing time-of-day with the current wall-clock time. So every reporting window was shifted by however late in the day you ran the tool:

  • Yesterday[May 24 14:54 → May 25 14:54) → wrongly swept in same-morning commits
  • Today[May 25 14:54 → May 26 14:54) → wrongly excluded those same commits

Fix

Added an anchorMidnight helper that pins bare ISO dates to 00:00:00 before handing them to git. Relative strings like "7 days ago" (from --since) pass through untouched.

Verification

Rebuilt and re-ran the TUI:

  • Yesterday → header 2026-05-24, only May 24 commits ✅
  • Today → header 2026-05-25, the 8 May 25 commits now appear (previously "nothing found") ✅

git's --since/--until parse a bare YYYY-MM-DD via approxidate, filling
the missing time-of-day with the current wall-clock time. This skewed
every reporting window by the time of day it was run -- e.g. the
"Yesterday" preset swept in same-morning commits while "Today" missed
them. Anchor bare ISO dates to 00:00:00 before passing them to git;
relative strings like "7 days ago" pass through untouched.
@ashishxcode ashishxcode merged commit 689836f into main May 25, 2026
3 checks passed
@ashishxcode ashishxcode deleted the fix/date-range-midnight-anchor branch May 25, 2026 09:28
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