Doctest failure when passing tz-aware datetime to a conversions/ date utility in thealgorithms/Python
0 reputation · 13 Jul 2021, 01:39 UTC
0 reputation · 13 Jul 2021, 01:39 UTC
I am working with the date/timestamp conversion utilities in the conversions/ directory of thealgorithms/Python and want to handle regional time zones correctly. My precise goal is to convert a Unix timestamp into a localized date string for a specific IANA zone (for example Europe/Berlin) using zoneinfo, while keeping the repo's doctest-based validation passing.
The existing conversion functions appear to assume naive datetimes and fixed format strings, and their doctests only exercise naive inputs. When a tzinfo-aware datetime is supplied, the expected-output doctests no longer match, which causes a pytest doctest failure — the project's primary correctness gate per its contributing guidelines. It is unclear whether the intended contract is that callers must pre-convert to UTC and pass naive values, or whether aware input is simply unsupported.
Assume a recent master checkout and Python 3.11+; behavior may be commit-sensitive since the repo has no stable releases.
zoneinfo-aware input, what doctest output convention should I follow so the CI doctest run stays deterministic across machine time zones?ValueError, given error handling is inconsistent across files?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.