Skip to content

Commit

Permalink
refactor: .utcnow() -> .now(utc)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKevJames committed Jan 30, 2024
1 parent 2ddff0b commit 80aa78c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions auth/gcloud/aio/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def ensure_token(self) -> None:
return

if self.access_token:
now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)
delta = (now - self.access_token_acquired_at).total_seconds()
if delta <= self.access_token_duration / 2:
return
Expand All @@ -232,7 +232,8 @@ async def acquire_access_token(self, timeout: int = 10) -> None:

self.access_token = resp.value
self.access_token_duration = resp.expires_in
self.access_token_acquired_at = datetime.datetime.utcnow()
self.access_token_acquired_at = datetime.datetime.now(
datetime.timezone.utc)
self.acquiring = None

async def close(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion storage/gcloud/aio/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def get_signed_url( # pylint: disable=too-many-locals
quoted_name = quote(self.name, safe=b'/~')
canonical_uri = f'/{self.bucket.name}/{quoted_name}'

datetime_now = datetime.datetime.utcnow()
datetime_now = datetime.datetime.now(datetime.timezone.utc)
request_timestamp = datetime_now.strftime('%Y%m%dT%H%M%SZ')
datestamp = datetime_now.strftime('%Y%m%d')

Expand Down

0 comments on commit 80aa78c

Please sign in to comment.