Skip to content

Add arrow.timezone() function for creating timezone objects#1299

Open
rtsdque wants to merge 2 commits into
arrow-py:masterfrom
rtsdque:feature-issue-912-timezone
Open

Add arrow.timezone() function for creating timezone objects#1299
rtsdque wants to merge 2 commits into
arrow-py:masterfrom
rtsdque:feature-issue-912-timezone

Conversation

@rtsdque

@rtsdque rtsdque commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Adds arrow.timezone() as a public function for creating timezone objects directly from the arrow module, without needing to import from datetime, ZoneInfo, or dateutil.

Usage

import arrow

arrow.now(tz=arrow.timezone("US/Pacific"))
arrow.timezone("UTC")
arrow.timezone("local")

Changes

  • arrow/api.py: Added timezone() function wrapping TzinfoParser.parse()
  • arrow/__init__.py: Exported timezone from the public module API
  • tests/test_api.py: Added 4 tests covering UTC, ZoneInfo, local, and invalid timezone strings

Testing

  • All 1905 tests passing
  • arrow/api.py at 100% coverage
  • Overall coverage: 99.93% (above the 99% threshold)
  • No new mypy errors introduced

Closes #912

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

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2224255) to head (b0f5c95).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

@rtsdque

rtsdque commented Jun 19, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create arrow timezone interface and wrapper

1 participant