diff options
| author | Vedran Karacic <karacicvedran@gmail.com> | 2025-12-12 10:04:19 +0100 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-29 11:28:13 -0400 |
| commit | 61941b6fc172933f425e8ba76bab444ab9b313e4 (patch) | |
| tree | a59cfb9faa571f6cc329ee8d0868578646169a2b /django | |
| parent | 604695cddb41981b84a8d976d1f4c74c39e112b0 (diff) | |
Fixed #35951 -- Mentioned server timezone in admin DateTime widgets.
The existing note that is shown to the users when entering a time value
from a different timezone than the server's timezone was not descriptive
enough and led to confusion. This commit updates the note to explicitly
state that the user should enter times in the server's timezone.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js | 20 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/base.html | 5 |
2 files changed, 18 insertions, 7 deletions
diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 6f71b25152..27223e2815 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -82,22 +82,32 @@ return; } + const serverTimezone = + document.body.dataset.adminServerTimezone || gettext("server"); let message; if (timezoneOffset > 0) { message = ngettext( - "Note: You are %s hour ahead of server time.", - "Note: You are %s hours ahead of server time.", + "Note: Enter times in the %(timezone)s timezone. " + + "(You are %(offset)s hour ahead.)", + "Note: Enter times in the %(timezone)s timezone. " + + "(You are %(offset)s hours ahead.)", timezoneOffset, ); } else { timezoneOffset *= -1; message = ngettext( - "Note: You are %s hour behind server time.", - "Note: You are %s hours behind server time.", + "Note: Enter times in the %(timezone)s timezone. " + + "(You are %(offset)s hour behind.)", + "Note: Enter times in the %(timezone)s timezone. " + + "(You are %(offset)s hours behind.)", timezoneOffset, ); } - message = interpolate(message, [timezoneOffset]); + message = interpolate( + message, + { timezone: serverTimezone, offset: timezoneOffset }, + true, + ); const warning = document.createElement("div"); const id = inp.id; diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index 066f5fa65c..8ef92802a9 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -1,4 +1,4 @@ -{% load i18n static %}<!DOCTYPE html> +{% load i18n static tz %}<!DOCTYPE html> {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" dir="{{ LANGUAGE_BIDI|yesno:'rtl,ltr,auto' }}"> <head> @@ -25,7 +25,8 @@ </head> <body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}" - data-admin-utc-offset="{% now "Z" %}"> + data-admin-utc-offset="{% now "Z" %}" + data-admin-server-timezone="{% get_current_timezone as time_zone %}{{ time_zone }}"> <a href="#content-start" class="skip-to-content-link">{% translate 'Skip to main content' %}</a> <!-- Container --> <div id="container"> |
