Fixed #25149 -- Replaced window.__admin_utc_offset__ with a data attribute.
This commit is contained in:
parent
5aba3f0a45
commit
8eeb566aca
|
@ -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));
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
|
||||
{% block extrastyle %}{% endblock %}
|
||||
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
|
||||
<script type="text/javascript">window.__admin_utc_offset__ = "{% filter escapejs %}{% now "Z" %}{% endfilter %}";</script>
|
||||
{% block extrahead %}{% endblock %}
|
||||
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
|
||||
</head>
|
||||
{% load i18n %}
|
||||
|
||||
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}">
|
||||
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
|
||||
data-admin-utc-offset="{% filter escapejs %}{% now "Z" %}{% endfilter %}">
|
||||
|
||||
<!-- Container -->
|
||||
<div id="container">
|
||||
|
|
|
@ -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 ``<body>`` tag.
|
||||
|
||||
* ``CommaSeparatedIntegerField`` validation has been refined to forbid values
|
||||
like ``','``, ``',1'``, and ``'1,,2'``.
|
||||
|
|
Loading…
Reference in New Issue