Skip to content

Commit 7edc316

Browse files
authored
Use time.time() to obtain unix timestamp
datetime.utcnow() returns an instance with no timezone information, and calling timestamp() on it applies a local to UTC conversion again. time.time() returns a unix timestamp directly, so there's no need to deal with UTC or timezone offsets.
1 parent ad38384 commit 7edc316

File tree

1 file changed

+2
-1
lines changed
  • mkdocs_git_revision_date_localized_plugin

1 file changed

+2
-1
lines changed

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# standard library
22
import logging
33
import os
4+
import time
45
from datetime import datetime
56

67
# 3rd party
@@ -116,7 +117,7 @@ def get_revision_date_for_file(
116117

117118
# create timestamp
118119
if not unix_timestamp:
119-
unix_timestamp = datetime.utcnow().timestamp()
120+
unix_timestamp = time.time()
120121
logging.warning("%s has no git logs, using current timestamp" % path)
121122

122123
return self._date_formats(unix_timestamp=unix_timestamp, locale=locale)

0 commit comments

Comments
 (0)