Skip to content

Commit f0988ef

Browse files
vr8hubacabal
vr8hub
authored andcommitted
Remove use of deprecated (python 3.12) datetime.utcnow function
1 parent 6640b70 commit f0988ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

se/se_epub.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import base64
88
from copy import deepcopy
9-
import datetime
9+
from datetime import datetime, timezone
1010
import os
1111
from pathlib import Path
1212
import importlib.resources
@@ -32,7 +32,7 @@ class GitCommit:
3232
short_sha = ""
3333
timestamp = None
3434

35-
def __init__(self, short_sha: str, timestamp: datetime.datetime):
35+
def __init__(self, short_sha: str, timestamp: datetime):
3636
self.short_sha = short_sha
3737
self.timestamp = timestamp
3838

@@ -216,7 +216,7 @@ def last_commit(self) -> Optional[GitCommit]:
216216
git_command = git.cmd.Git(self.path)
217217
output = git_command.show("-s", "--format=%h %ct", "HEAD").split()
218218

219-
self._last_commit = GitCommit(output[0], datetime.datetime.fromtimestamp(int(output[1]), datetime.timezone.utc))
219+
self._last_commit = GitCommit(output[0], datetime.fromtimestamp(int(output[1]), timezone.utc))
220220
except Exception:
221221
self._last_commit = None
222222

@@ -1017,7 +1017,7 @@ def set_release_timestamp(self) -> None:
10171017
"""
10181018

10191019
if self.metadata_dom.xpath("/package/metadata/dc:date[text() = '1900-01-01T00:00:00Z']"):
1020-
now = datetime.datetime.utcnow()
1020+
now = datetime.now(timezone.utc)
10211021
now_iso = regex.sub(r"\.[0-9]+$", "", now.isoformat()) + "Z"
10221022
now_iso = regex.sub(r"\+.+?Z$", "Z", now_iso)
10231023
now_friendly = f"{now:%B %e, %Y, %l:%M <abbr class=\"eoc\">%p</abbr>}"

0 commit comments

Comments
 (0)