System (or "local") time zone implementation for tz_local that can handle DST and time zone transitions and is based on the time module#14
Open
blubberdiblub wants to merge 7 commits intochannable:add-foldfrom
Conversation
We need to adjust `sys.path` to ensure the right package is tested at all times (rather than a potentially installed one). conftest.py is the ideal place to do this as pytest ensures a file with this name is imported first (you can also place pytest hooks there). At the same time this allows us to get rid of the absolute imports from tests.shared and use more robust relative imports instead.
`SystemTZ` is a subclass of `datetime.tzinfo` and is API compatible with `ZoneInfo`. Instances of the class represent the time zone the system (or the application) is configured to. It implements this via delegating to `time.*` functionality and is sensitive to and supports changing the time zone via setting the `TZ` environment variable and subsequently calling `time.tzset()` on systems that provide this function (not Windows). We also add a test suite with an extensive list of datetimes lots of which are potentially tricky corner cases to ensure that the implementation is not faulty.
Contributor
|
@blubberdiblub, thanks for your contribution! Do you mind rebasing this PR, then I will try to have a look at it |
|
Sorry, me removing the |
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.
This addresses one of Arie Bovenberg's complaints in #12 regarding the
tz_localattribute of heliclockter. It provides an own implementation that doesn't need thetzlocalmodule (but can optionally utilize it to return a more useful value from the.keyattribute if it happens to be installed) and is properly sensitive toTZandtime.tzset().Note that this pull request depends on the fold attribute added in #13 which hasn't been merged yet (and as such is built on top of the commits from the
add-foldbranch). So please don't consider merging this before the other pull request has been merged and this one properly rebased against the resulting master.It's also fine to reject the pull request, if you don't want or need this in heliclockter.
Note that this also brings along a test suite with extensive checks against dates and times, many of which are possible edge cases. The test scaffolding could also be utilized for other existing tests. E.g. in
instantiation_test.pyit says "We cannot testdatetime_localas the expected hour will vary on the system testing", which used to be true, but with thetzset,systemtzandwelldefined_timezonefixtures it's now possible to test it as well. For that, it'd likely be desirable to move the fixtures to a more central place, such asconftest.py, which would make them available to all tests.