You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Datetime docs on determining tz-awareness can be simplified with utcoffset method #160035
It appears that this can be simplfied to a single check of d.utcoffset() is None (and likewise for time objects) since the docs for the datetime.utcoffset() method say it incorporates both steps:
If tzinfo is None, returns None, else returns self.tzinfo.utcoffset(self) ...
This method does also do some extra checks ("raises an exception if the latter doesn’t return None or a timedelta object with magnitude less than one day"), but that appears to be only to catch badly implemented tzinfo objects, so it doesn't seem like a reason not to use it.
I'd like to work on this documentation improvement. I'll check the existing datetime documentation and propose a minimal change using d.utcoffset() is None, while preserving the explanation of timezone-aware and naive objects. Please let me know if someone is already working on it.
Activity
Milan-CSE commentedon Oct 21, 2026
I'd like to work on this documentation improvement. I'll check the existing
datetimedocumentation and propose a minimal change usingd.utcoffset() is None, while preserving the explanation of timezone-aware and naive objects. Please let me know if someone is already working on it.gh-160035: Simplify datetime awareness docs (#160086)
[3.15] gh-160035: Simplify datetime awareness docs (GH-160086) (#160211)
[3.14] gh-160035: Simplify datetime awareness docs (GH-160086) (#160212)