Skip to content

Commit

Permalink
Merge pull request #8685 from tk0miya/8683_strftime_z
Browse files Browse the repository at this point in the history
Fix #8683: html_last_updated_fmt does not support UTC offset (%z)
  • Loading branch information
tk0miya committed Jan 13, 2021
2 parents b742bde + 8ff8b55 commit d635d94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -54,6 +54,8 @@ Bugs fixed
* #8671: :confval:`highlight_options` is not working
* #8341: C, fix intersphinx lookup types for names in declarations.
* C, C++: in general fix intersphinx and role lookup types.
* #8683: :confval:`html_last_updated_fmt` does not support UTC offset (%z)
* #8683: :confval:`html_last_updated_fmt` generates wrong time zone for %Z

Testing
--------
Expand Down
4 changes: 3 additions & 1 deletion sphinx/util/i18n.py
Expand Up @@ -236,7 +236,9 @@ def find_catalog_source_files(locale_dirs: List[str], locale: str, domains: List
'%X': 'medium', # Locale’s appropriate time representation.
'%y': 'YY', # Year without century as a zero-padded decimal number.
'%Y': 'yyyy', # Year with century as a decimal number.
'%Z': 'zzzz', # Time zone name (no characters if no time zone exists).
'%Z': 'zzz', # Time zone name (no characters if no time zone exists).
'%z': 'ZZZ', # UTC offset in the form ±HHMM[SS[.ffffff]]
# (empty string if the object is naive).
'%%': '%',
}

Expand Down
6 changes: 6 additions & 0 deletions tests/test_util_i18n.py
Expand Up @@ -87,6 +87,12 @@ def test_format_date():
assert i18n.format_date(format, date=datet) == 'Feb 7, 2016, 5:11:17 AM'
assert i18n.format_date(format, date=date) == 'Feb 7, 2016'

# timezone
format = '%Z'
assert i18n.format_date(format, date=datet) == 'UTC'
format = '%z'
assert i18n.format_date(format, date=datet) == '+0000'


@pytest.mark.xfail(os.name != 'posix', reason="Path separators don't match on windows")
def test_get_filename_for_language(app):
Expand Down

0 comments on commit d635d94

Please sign in to comment.