Replace S2 timezone handling from pytz to zoneinfo#192
Merged
Conversation
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures-client/sessions/a3fc7d1d-eeb5-4f50-931b-d3c93a5d65a3 Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Replace pytz library with zoneinfo in s2 directory
Replace S2 timezone handling from Mar 31, 2026
pytz to zoneinfo
nhoening
reviewed
Mar 31, 2026
nhoening
approved these changes
Mar 31, 2026
Flix6x
approved these changes
Apr 1, 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.
S2 modules were still relying on
pytz(timezone()/localize()), which is legacy for modern Python timezone handling. This change migrates S2 timezone construction and aware datetime creation to stdlibzoneinfo.Scope: S2 timezone migration
pytzimports/usages withzoneinfo.ZoneInfoin:src/flexmeasures_client/s2/__init__.pysrc/flexmeasures_client/s2/control_types/FRBC/frbc_simple.pysrc/flexmeasures_client/s2/control_types/FRBC/frbc_tunes.pysrc/flexmeasures_client/s2/script/websockets_client.pyBehavioral updates
pytz.timezone(name)→ZoneInfo(name)pytz.localize(...)pattern with native aware datetime construction:datetime(..., tzinfo=ZoneInfo(...))FRBCSimple.now()to generate aware datetimes via:datetime.now(self._timezone)Focused coverage
tests/s2/test_timezone.pyto assert S2now()paths produceZoneInfo-backed datetimes (Handler,FRBCSimple).