Repository navigation
fix(fmt): не падать на Windows при --since all - #1
Merged
Merged
Conversation
`--since all` задаёт точкой отсчёта ts=1, а `datetime.fromtimestamp(ts)` без tz на Windows бросает OSError [Errno 22] для первых часов эпохи: пересчёт naive-времени в местное уходит за 1970-01-01 UTC. На Linux и macOS не воспроизводится. Считаем время сразу в UTC и переводим в местное через astimezone() — результат тот же, но без обращения к localtime для дат до эпохи. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nowherewashere
added a commit
that referenced
this pull request
Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что не так
На Windows
study state --since allпадает:Почему
При
--since allload_stateвозвращает точку отсчётаts=1(snapshot.py:69). Дальшеmoment()зовётfromtimestamp(ts)без tz — получается naive-время, и.astimezone()просит систему определить местное смещение для 1 января 1970. На Windows это OSError: при UTC+3 пересчёт уходит за начало эпохи.Windows 11, Python 3.13.3, MSK (UTC+3):
fromtimestamp(ts).astimezone()На Linux и macOS не воспроизводится, поэтому в CI не видно.
Что сделано
fromtimestamp(ts, datetime.timezone.utc)— время сразу aware в UTC, аastimezone()переводит его в местное без обращения к localtime для дат до эпохи. Для всех остальных значений результат не меняется:Соседние
time.localtime()трогать не нужно — они на Windows отрабатывают корректно и дляts=0.Проверка
py -m unittest discover -s tests -t .— 122 теста, OK (1 skipped), Windows 11 / Python 3.13.3.🤖 Generated with Claude Code