diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 871b96cfd4..b41c0cd505 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -18,8 +18,9 @@ var DateTimeShortcuts = { timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch timezoneOffset: 0, init: function() { - if (window.__admin_utc_offset__ !== undefined) { - var serverOffset = window.__admin_utc_offset__; + var body = document.getElementsByTagName('body')[0]; + var serverOffset = body.getAttribute('data-admin-utc-offset'); + if (serverOffset !== undefined) { var localOffset = new Date().getTimezoneOffset() * -60; DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; } @@ -39,8 +40,9 @@ var DateTimeShortcuts = { }, // Return the current time while accounting for the server timezone. now: function() { - if (window.__admin_utc_offset__ !== undefined) { - var serverOffset = window.__admin_utc_offset__; + var body = document.getElementsByTagName('body')[0]; + var serverOffset = body.getAttribute('data-admin-utc-offset'); + if (serverOffset !== undefined) { var localNow = new Date(); var localOffset = localNow.getTimezoneOffset() * -60; localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset)); diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index 77fdf5bb2f..fa6ee41b08 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -6,13 +6,13 @@ {% block extrastyle %}{% endblock %} {% if LANGUAGE_BIDI %}{% endif %} - {% block extrahead %}{% endblock %} {% block blockbots %}{% endblock %} {% load i18n %} - +
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 693ba7c521..148e857c86 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -846,9 +846,10 @@ Miscellaneous * ``ValuesQuerySet`` and ``ValuesListQuerySet`` have been removed. * The ``admin/base.html`` template no longer sets - ``window.__admin_media_prefix__``. Image references in JavaScript that used - that value to construct absolute URLs have been moved to CSS for easier - customization. + ``window.__admin_media_prefix__`` or ``window.__admin_utc_offset__``. Image + references in JavaScript that used that value to construct absolute URLs have + been moved to CSS for easier customization. The UTC offset is stored on a + data attribute of the ```` tag. * ``CommaSeparatedIntegerField`` validation has been refined to forbid values like ``','``, ``',1'``, and ``'1,,2'``.