Skip to content

fix: use UTC timezone for timestamp conversion#48

Merged
jrepp merged 1 commit intomainfrom
fix/timezone-conversion
Feb 4, 2026
Merged

fix: use UTC timezone for timestamp conversion#48
jrepp merged 1 commit intomainfrom
fix/timezone-conversion

Conversation

@jrepp
Copy link
Owner

@jrepp jrepp commented Feb 4, 2026

Summary

Fix timezone conversion bug in timestamps.py that caused timestamps to be offset by the local timezone.

Root cause: The code used astimezone(tz=None) which converts to local timezone, but then formatted with 'Z' suffix which implies UTC.

Example with CST (UTC-6) local timezone:

  • Git timestamp: 2025-10-16T23:09:56-07:00 (PDT)
  • Bug output: 2025-10-17T01:09:56Z (local time incorrectly marked as UTC)
  • Fixed output: 2025-10-17T06:09:56Z (actual UTC)

Changes

Changed astimezone(tz=None) to astimezone(timezone.utc) for both created and updated timestamp conversions in get_git_dates().

Test plan

  • All existing timestamp tests pass (32 tests)
  • Verified fix produces correct UTC timestamps

The previous code used `astimezone(tz=None)` which converts to local
timezone, but then formatted with 'Z' suffix which implies UTC. This
caused timestamps to be offset by the local timezone.

Example with CST (UTC-6):
- Git timestamp: 2025-10-16T23:09:56-07:00
- Bug output: 2025-10-17T01:09:56Z (local time with Z suffix)
- Fixed output: 2025-10-17T06:09:56Z (actual UTC)

Changed `astimezone(tz=None)` to `astimezone(timezone.utc)` for both
created and updated timestamp conversions.
@jrepp jrepp merged commit d478b98 into main Feb 4, 2026
8 checks passed
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