Skip to content

Commit 423b554

Browse files
committed
Fix bug where timezone setting was not properly used
1 parent 01d8bc5 commit 423b554

File tree

1 file changed

+6
-3
lines changed
  • mkdocs_git_revision_date_localized_plugin

1 file changed

+6
-3
lines changed

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def _date_formats(
5959
Returns:
6060
dict: Different date formats.
6161
"""
62+
assert time_zone is not None
63+
assert locale is not None
64+
6265
utc_revision_date = datetime.utcfromtimestamp(int(unix_timestamp))
6366
loc_revision_date = utc_revision_date.replace(
6467
tzinfo=get_timezone("UTC")
@@ -108,7 +111,7 @@ def get_git_commit_timestamp(
108111
if is_first_commit:
109112
# diff_filter="A" will select the commit that created the file
110113
commit_timestamp = git.log(
111-
realpath, date="short", format="%at", diff_filter="A"
114+
realpath, date="unix", format="%at", diff_filter="A"
112115
)
113116
# A file can be created multiple times, through a file renamed.
114117
# Commits are ordered with most recent commit first
@@ -118,7 +121,7 @@ def get_git_commit_timestamp(
118121
else:
119122
# Latest commit touching a specific file
120123
commit_timestamp = git.log(
121-
realpath, date="short", format="%at", n=1
124+
realpath, date="unix", format="%at", n=1
122125
)
123126
except (InvalidGitRepositoryError, NoSuchPathError) as err:
124127
if self.config.get('fallback_to_build_date'):
@@ -190,7 +193,7 @@ def get_date_formats_for_timestamp(
190193
"""
191194
date_formats = self._date_formats(
192195
unix_timestamp=commit_timestamp,
193-
time_zone=self.config.get("time_zone"),
196+
time_zone=self.config.get("timezone"),
194197
locale=self.config.get("locale")
195198
)
196199
if add_spans:

0 commit comments

Comments
 (0)