Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated datetime.datetime.now #2414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions win32/Lib/win32timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def local(class_):
registry.
>>> localTZ = TimeZoneInfo.local()
>>> now_local = datetime.datetime.now(localTZ)
>>> now_UTC = datetime.datetime.utcnow()
>>> now_UTC = datetime.datetime.now(datetime.timezone.utc)
>>> (now_UTC - now_local) < datetime.timedelta(seconds = 5)
Traceback (most recent call last):
...
Expand Down Expand Up @@ -895,18 +895,18 @@ def _enumerate_reg(key, func):
pass


def utcnow():
def utcnow() -> datetime.datetime:
"""
Return the UTC time now with timezone awareness as enabled
by this module
>>> now = utcnow()
"""
now = datetime.datetime.utcnow()
now = now.replace(tzinfo=TimeZoneInfo.utc())
return now
return datetime.datetime.now(datetime.timezone.utc).replace(
tzinfo=TimeZoneInfo.utc()
)


def now():
def now() -> datetime.datetime:
"""
Return the local time now with timezone awareness as enabled
by this module
Expand Down
Loading