Rename `html_last_updated_time_zone to html_last_updated_use_utc` (#12958)

This commit is contained in:
Adam Turner 2024-10-05 16:34:00 +01:00 committed by GitHub
parent 86531aba8e
commit 4c638d8289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 13 deletions

View File

@ -49,8 +49,8 @@ Features added
* #12743: Add :option:`sphinx-build --exception-on-warning`,
to raise an exception when warnings are emitted during the build.
Patch by Adam Turner and Jeremy Maitin-Shepard.
* #12907: Add :confval:`html_last_updated_time_zone` to allow using
GMT (universal time) instead of local time for the date-time
* #12907: Add :confval:`html_last_updated_use_utc` to allow using
universal time (GMT/UTC) instead of local time for the date-time
supplied to :confval:`html_last_updated_fmt`.
Patch by Adam Turner.
* #12910: Copyright entries now support the ``'%Y'`` placeholder

View File

@ -45,7 +45,6 @@ html_additional_pages = {'contents': 'contents.html'}
html_use_opensearch = 'https://www.sphinx-doc.org/en/master'
html_baseurl = 'https://www.sphinx-doc.org/en/master/'
html_favicon = '_static/favicon.svg'
html_last_updated_time_zone = 'GMT'
htmlhelp_basename = 'Sphinxdoc'

View File

@ -1730,11 +1730,11 @@ and also make use of these options.
The empty string is equivalent to :code-py:`'%b %d, %Y'`
(or a locale-dependent equivalent).
.. confval:: html_last_updated_time_zone
:type: :code-py:`'local' | 'GMT'`
:default: :code-py:`'local'`
.. confval:: html_last_updated_use_utc
:type: :code-py:`bool`
:default: :code-py:`False`
Choose GMT (+00:00) or the system's local time zone
Use GMT/UTC (+00:00) instead of the system's local time zone
for the time supplied to :confval:`html_last_updated_fmt`.
This is most useful when the format used includes the time.

View File

@ -473,10 +473,10 @@ class StandaloneHTMLBuilder(Builder):
# typically doesn't include the time of day
last_updated: str | None
if (lu_fmt := self.config.html_last_updated_fmt) is not None:
lu_fmt = lu_fmt or _('%b %d, %Y')
local_time = self.config.html_last_updated_time_zone == 'local'
last_updated = format_date(
lu_fmt, language=self.config.language, local_time=local_time
lu_fmt or _('%b %d, %Y'),
language=self.config.language,
local_time=not self.config.html_last_updated_use_utc,
)
else:
last_updated = None
@ -1423,9 +1423,7 @@ def setup(app: Sphinx) -> ExtensionMetadata:
app.add_config_value('html_static_path', [], 'html')
app.add_config_value('html_extra_path', [], 'html')
app.add_config_value('html_last_updated_fmt', None, 'html', str)
app.add_config_value(
'html_last_updated_time_zone', 'local', 'html', ENUM('GMT', 'local')
)
app.add_config_value('html_last_updated_use_utc', False, 'html', types={bool})
app.add_config_value('html_sidebars', {}, 'html')
app.add_config_value('html_additional_pages', {}, 'html')
app.add_config_value('html_domain_indices', True, 'html', types={set, list})