Datetime timezone awareness#1590
Conversation
…deo module as to not conflict with other tests
|
Ready for review. I skimmed the codebase for |
There was a problem hiding this comment.
Pull request overview
Adds an optional global timezone setting so plexapi.utils.toDatetime() can return timezone-aware datetime objects (driven by new plexapi.timezone config), with accompanying docs and tests.
Changes:
- Introduces
plexapi.utils.setDatetimeTimezone()+ a globalDATETIME_TIMEZONEused bytoDatetime(). - Initializes the timezone setting from
config.iniduringplexapiimport. - Documents the new config option and adds tests for timezone-aware/naive behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
plexapi/utils.py |
Adds timezone configuration + applies it in toDatetime() conversions. |
plexapi/__init__.py |
Loads plexapi.timezone from config and initializes global timezone behavior. |
docs/configuration.rst |
Documents the new timezone setting and its behavior/risks. |
tests/test_utils.py |
Adds unit tests for setDatetimeTimezone() and toDatetime() tz-awareness. |
tests/test_video.py |
Adds an integration-style test asserting media datetimes become aware/naive based on configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…(e.g. alpine, windows) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…lready has timezone info
…NE` in sync (aliased)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Add optional timezone‑awareness for all parsed Plex datetime objects.
The PR introduces a
plexapi.timezoneconfig option (acceptsboolor IANA time zonestr). The configured time zone is parsed and globally defined. Subsequent calls to theutils.toDatetime()helper will normalize timestamps using that time zone.Note: I've documented that "Toggling this option may break comparisons between aware and naive datetimes." Python's datetime does not support comparing naive and aware datetime objects (e.g.
some_tz_aware_dt >= some_naive_dtwill raise aTypeError).Type of change
Checklist: