Skip to content

fix: use UTC in fromtimestamp to avoid OSError on Windows for epoch≈0#14

Merged
shigechika merged 1 commit into
mainfrom
fix/format-ts-utc
May 1, 2026
Merged

fix: use UTC in fromtimestamp to avoid OSError on Windows for epoch≈0#14
shigechika merged 1 commit into
mainfrom
fix/format-ts-utc

Conversation

@shigechika
Copy link
Copy Markdown
Owner

Summary

  • datetime.fromtimestamp(ts) raises OSError on Windows when ts is near 0 (pre-1970 values in local time). Passing tz=timezone.utc makes the call well-defined on all platforms; .astimezone() then converts to local time for display — identical output for normal timestamps.
  • Same fix applied to the two inline fromtimestamp calls in get_login_stats_by_hour (lines 448/454), which had the same issue but were not covered by _format_ts.
  • OSError removed from the _format_ts except clause (now unreachable).
  • @pytest.mark.skipif(sys.platform == "win32", ...) guard on TestFormatTs::test_zero removed; import sys and import pytest (now unused) also removed.

Test plan

  • uv run pytest -v — 70 tests pass (no skips on any platform)
  • uv run ruff check + ruff format --check — clean
  • CI green on ubuntu-latest × 3.10/3.12/3.13 + windows-latest × 3.12

Closes #4

🤖 Generated with Claude Code

datetime.fromtimestamp(ts) raises OSError on Windows when ts is near 0
(pre-1970 local time).  Passing tz=timezone.utc makes the call
well-defined on all platforms; .astimezone() then converts to local time
for display.

Also applies the same fix to the two inline fromtimestamp calls in
get_login_stats_by_hour.  OSError removed from _format_ts except clause
(now unreachable).  Windows skipif guard on TestFormatTs::test_zero
removed.

Closes #4

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@shigechika shigechika merged commit 3556dcd into main May 1, 2026
5 checks passed
@shigechika shigechika deleted the fix/format-ts-utc branch May 1, 2026 15:50
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.

_format_ts: use UTC to avoid OSError on Windows for epoch values near 0

1 participant