Skip to content

Commit

Permalink
Fix bug where timezone setting was not properly used
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink committed Feb 7, 2022
1 parent 01d8bc5 commit 423b554
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mkdocs_git_revision_date_localized_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def _date_formats(
Returns:
dict: Different date formats.
"""
assert time_zone is not None
assert locale is not None

utc_revision_date = datetime.utcfromtimestamp(int(unix_timestamp))
loc_revision_date = utc_revision_date.replace(
tzinfo=get_timezone("UTC")
Expand Down Expand Up @@ -108,7 +111,7 @@ def get_git_commit_timestamp(
if is_first_commit:
# diff_filter="A" will select the commit that created the file
commit_timestamp = git.log(
realpath, date="short", format="%at", diff_filter="A"
realpath, date="unix", format="%at", diff_filter="A"
)
# A file can be created multiple times, through a file renamed.
# Commits are ordered with most recent commit first
Expand All @@ -118,7 +121,7 @@ def get_git_commit_timestamp(
else:
# Latest commit touching a specific file
commit_timestamp = git.log(
realpath, date="short", format="%at", n=1
realpath, date="unix", format="%at", n=1
)
except (InvalidGitRepositoryError, NoSuchPathError) as err:
if self.config.get('fallback_to_build_date'):
Expand Down Expand Up @@ -190,7 +193,7 @@ def get_date_formats_for_timestamp(
"""
date_formats = self._date_formats(
unix_timestamp=commit_timestamp,
time_zone=self.config.get("time_zone"),
time_zone=self.config.get("timezone"),
locale=self.config.get("locale")
)
if add_spans:
Expand Down

0 comments on commit 423b554

Please sign in to comment.