Add arrow.timezone() function for creating timezone objects#1299
Open
rtsdque wants to merge 2 commits into
Open
Add arrow.timezone() function for creating timezone objects#1299rtsdque wants to merge 2 commits into
rtsdque wants to merge 2 commits into
Conversation
Adds a public arrow.timezone() wrapper around TzinfoParser.parse() so users can create timezone objects directly from the arrow module without importing from datetime, ZoneInfo, or dateutil. Usage: arrow.now(tz=arrow.timezone('US/Pacific'))
Closes arrow-py#912
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1299 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2318 +3
Branches 358 358
=========================================
+ Hits 2315 2318 +3 ☔ View full report in Codecov by Harness. |
Author
|
The linting issues have been fixed. The remaining failure (windows-latest pypy-3.11) is a network error during CI setup (IncompleteRead while downloading pyyaml), unrelated to this change. All 26 other checks pass including linting, codecov at 100% diff coverage, and tests across Python 3.8 through 3.13 on macOS, Ubuntu, and Windows. |
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.
Summary
Adds
arrow.timezone()as a public function for creating timezone objects directly from the arrow module, without needing to import fromdatetime,ZoneInfo, ordateutil.Usage
Changes
arrow/api.py: Addedtimezone()function wrappingTzinfoParser.parse()arrow/__init__.py: Exportedtimezonefrom the public module APItests/test_api.py: Added 4 tests covering UTC, ZoneInfo, local, and invalid timezone stringsTesting
arrow/api.pyat 100% coverageCloses #912