Skip to content

Commit

Permalink
Fix datetime.datetime.utcnow() deprecation warning.
Browse files Browse the repository at this point in the history
Python 3.12 will print the following warning when using
`datetime.datetime.utcnow()`:

  DeprecationWarning: datetime.datetime.utcnow() is deprecated and
  scheduled for removal in a future version. Use timezone-aware objects
  to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

Follow the suggestion, except we don't use `datetime.UTC` to avoid
breaking compatibility with Python 3.6.
  • Loading branch information
joanbm committed May 12, 2024
1 parent 0d64803 commit bcef9c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion full_offline_backup_for_todoist/backup_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def download(self, vfs: VirtualFs) -> None:

# Sanitize the file name for platforms such as Windows,
# which don't accept some characters in file names, such as a colon (:)
backup_version = datetime.datetime.utcnow().replace(microsecond=0).isoformat(' ')
backup_version = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
vfs.set_path_hint(sanitize_file_name("TodoistBackup_" + backup_version))

# Download the file
Expand Down

0 comments on commit bcef9c6

Please sign in to comment.