Skip to content

Commit ff6811d

Browse files
committed
add timezone to title in span
1 parent 2fd812f commit ff6811d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/mkdocs_git_revision_date_localized_plugin/dates.py

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def get_date_formats(
3333
loc_revision_date.strftime("%H:%M:%S"),
3434
]
3535
),
36+
"datetime-timezone": " ".join(
37+
[
38+
format_date(loc_revision_date, format="long", locale=locale),
39+
loc_revision_date.strftime("%H:%M:%S %Z"),
40+
]
41+
),
3642
"iso_date": loc_revision_date.strftime("%Y-%m-%d"),
3743
"iso_datetime": loc_revision_date.strftime("%Y-%m-%d %H:%M:%S"),
3844
"timeago": '<span class="timeago" datetime="%s" locale="%s"></span>' % (loc_revision_date.isoformat(), locale),

src/mkdocs_git_revision_date_localized_plugin/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def add_spans(date_formats: Dict[str, str]) -> Dict[str, str]:
230230
"""
231231
Wraps the date string in <span> elements with CSS identifiers.
232232
"""
233-
datetime_string = date_formats["datetime"]
233+
datetime_string = date_formats["datetime-timezone"]
234234
for date_type, date_string in date_formats.items():
235235
date_formats[date_type] = (
236236
'<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-%s" title="%s">%s</span>'

tests/test_dates.py

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def test_get_dates():
1010
expected_output = {
1111
"date": "January 1, 1970",
1212
"datetime": "January 1, 1970 00:00:00",
13+
"datetime-timezone": "January 1, 1970 00:00:00 UTC",
1314
"iso_date": "1970-01-01",
1415
"iso_datetime": "1970-01-01 00:00:00",
1516
"timeago": '<span class="timeago" datetime="1970-01-01T00:00:00+00:00" locale="en"></span>',
@@ -26,6 +27,7 @@ def test_get_dates():
2627
expected_output = {
2728
"date": "1 janvier 1970",
2829
"datetime": "1 janvier 1970 00:00:00",
30+
"datetime-timezone": "1 janvier 1970 00:00:00 UTC",
2931
"iso_date": "1970-01-01",
3032
"iso_datetime": "1970-01-01 00:00:00",
3133
"timeago": '<span class="timeago" datetime="1970-01-01T00:00:00+00:00" locale="fr"></span>',
@@ -37,6 +39,7 @@ def test_get_dates():
3739
expected_output = {
3840
"date": "1 de janeiro de 1970",
3941
"datetime": "1 de janeiro de 1970 00:00:00",
42+
"datetime-timezone": "1 de janeiro de 1970 00:00:00 UTC",
4043
"iso_date": "1970-01-01",
4144
"iso_datetime": "1970-01-01 00:00:00",
4245
"timeago": '<span class="timeago" datetime="1970-01-01T00:00:00+00:00" locale="pt_BR"></span>',
@@ -52,6 +55,7 @@ def test_get_dates():
5255
expected_output = {
5356
"date": "January 1, 1970",
5457
"datetime": "January 1, 1970 00:00:00",
58+
"datetime-timezone": "January 1, 1970 00:00:00 UTC",
5559
"iso_date": "1970-01-01",
5660
"iso_datetime": "1970-01-01 00:00:00",
5761
"timeago": '<span class="timeago" datetime="1970-01-01T00:00:00+00:00" locale="en"></span>',
@@ -63,6 +67,7 @@ def test_get_dates():
6367
expected_output = {
6468
"date": "January 1, 1970",
6569
"datetime": "January 1, 1970 02:00:00",
70+
"datetime-timezone": "January 1, 1970 02:00:00 CET",
6671
"iso_date": "1970-01-01",
6772
"iso_datetime": "1970-01-01 02:00:00",
6873
"timeago": '<span class="timeago" datetime="1970-01-01T02:00:00+01:00" locale="en"></span>',
@@ -84,6 +89,7 @@ def test_get_dates():
8489
expected_output = {
8590
"date": "October 15, 2023",
8691
"datetime": "October 15, 2023 13:32:04",
92+
"datetime-timezone": "October 15, 2023 13:32:04 CEST",
8793
"iso_date": "2023-10-15",
8894
"iso_datetime": "2023-10-15 13:32:04",
8995
"timeago": '<span class="timeago" datetime="2023-10-15T13:32:04+02:00" locale="en"></span>',
@@ -94,6 +100,7 @@ def test_get_dates():
94100
assert get_date_formats(1582397529) == {
95101
"date": "February 22, 2020",
96102
"datetime": "February 22, 2020 18:52:09",
103+
"datetime-timezone": "February 22, 2020 18:52:09 UTC",
97104
"iso_date": "2020-02-22",
98105
"iso_datetime": "2020-02-22 18:52:09",
99106
"timeago": '<span class="timeago" datetime="2020-02-22T18:52:09+00:00" locale="en"></span>',

0 commit comments

Comments
 (0)