Skip to content

Commit

Permalink
RF: replace use of deprecated utcnow()
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Nov 20, 2023
1 parent 49fa7af commit e7711b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dandi/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Commands definition for DANDI command line interface
"""

from datetime import datetime
from datetime import UTC, datetime

This comment has been minimized.

Copy link
@jwodder

jwodder Nov 20, 2023

Member

datetime.UTC was only added in Python 3.11. You should use timezone.utc instead.

import logging
import os
import os.path
Expand Down Expand Up @@ -99,7 +99,7 @@ def main(ctx, log_level, pdb=False):

logdir = platformdirs.user_log_dir("dandi-cli", "dandi")
logfile = os.path.join(
logdir, f"{datetime.utcnow():%Y%m%d%H%M%SZ}-{os.getpid()}.log"
logdir, f"{datetime.now(UTC):%Y%m%d%H%M%SZ}-{os.getpid()}.log"
)
os.makedirs(logdir, exist_ok=True)
handler = logging.FileHandler(logfile, encoding="utf-8")
Expand Down
2 changes: 1 addition & 1 deletion dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_utcnow_datetime(microseconds: bool = True) -> datetime.datetime:
If string representation is desired, just "apply" .isoformat()
"""
ret = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone()
ret = datetime.datetime.now(datetime.UTC).astimezone()
if microseconds:
return ret
else:
Expand Down

0 comments on commit e7711b6

Please sign in to comment.