mirror of
https://github.com/python/cpython.git
synced 2025-10-24 02:13:49 +00:00
gh-91928: Add datetime.UTC alias for datetime.timezone.utc (GH-91973)
### fixes #91928 `UTC` is now module attribute aliased to `datetime.timezone.utc`. You can now do the following: ```python from datetime import UTC ```
This commit is contained in:
parent
ee2205b208
commit
48c6165c28
6 changed files with 23 additions and 3 deletions
|
|
@ -5,7 +5,7 @@
|
|||
"""
|
||||
|
||||
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
|
||||
"MINYEAR", "MAXYEAR")
|
||||
"MINYEAR", "MAXYEAR", "UTC")
|
||||
|
||||
|
||||
import time as _time
|
||||
|
|
@ -2290,7 +2290,8 @@ def _name_from_offset(delta):
|
|||
return f'UTC{sign}{hours:02d}:{minutes:02d}:{seconds:02d}'
|
||||
return f'UTC{sign}{hours:02d}:{minutes:02d}'
|
||||
|
||||
timezone.utc = timezone._create(timedelta(0))
|
||||
UTC = timezone.utc = timezone._create(timedelta(0))
|
||||
|
||||
# bpo-37642: These attributes are rounded to the nearest minute for backwards
|
||||
# compatibility, even though the constructor will accept a wider range of
|
||||
# values. This may change in the future.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue