Skip to content

fix: Normalize datetimes for timezone-aware vs naive comparison#40

Merged
evansenter merged 1 commit into
mainfrom
fix/timezone-comparison
Jan 2, 2026
Merged

fix: Normalize datetimes for timezone-aware vs naive comparison#40
evansenter merged 1 commit into
mainfrom
fix/timezone-comparison

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

Test plan

  • All 259 existing tests pass
  • New unit tests for normalize_datetime() in test_queries.py
  • Regression test with timezone-aware commit in test_ingest.py
  • CI passes

🤖 Generated with Claude Code

Fixes #34 - TypeError when comparing timezone-aware git commit timestamps
with naive session timestamps from SQLite.

- Add normalize_datetime() helper in queries.py that strips timezone info
  while preserving local time values
- Apply normalization in correlate_git_with_sessions() for both session
  ranges and commit timestamps
- Remove pytest.skip workarounds from test_server.py and test_cli.py
- Add regression test with timezone-aware commit in test_ingest.py
- Add unit tests for normalize_datetime in test_queries.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 2, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR fixes issue #34 by adding a normalize_datetime() helper function that strips timezone info from datetime objects, enabling safe comparison between timezone-aware git commit timestamps and naive session timestamps stored in SQLite.

Issues Found

Critical

None

Important

None

Suggestions

None

Verdict

APPROVE - Code looks good, no issues found.

The implementation is well-designed:

  • The normalize_datetime() function correctly strips timezone info while preserving local time values, which is the right approach given that SQLite stores naive local time
  • The docstring clearly explains the rationale for not converting to UTC
  • The function is applied at both comparison points in correlate_git_with_sessions() (session ranges and commit times)
  • Comprehensive test coverage including unit tests for the helper function and a regression test that exercises the full correlation flow
  • The pytest.skip() workarounds are correctly removed from both test_cli.py and test_server.py
  • The function is properly exported in __init__.py for public API access

Automated review by Claude Code

@evansenter evansenter merged commit 3dca641 into main Jan 2, 2026
3 checks passed
@evansenter evansenter deleted the fix/timezone-comparison branch January 2, 2026 06:02
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.

Fix timezone-aware vs naive datetime comparison in correlate_git_with_sessions

1 participant