Commit 9af40f5d authored by Sven Grunewaldt's avatar Sven Grunewaldt Committed by Tim Graham
Browse files

Fixed #25845 -- Fixed incorrect timezone warnings in custom admin templates.

parent d91cc25a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
        init: function() {
            var body = document.getElementsByTagName('body')[0];
            var serverOffset = body.getAttribute('data-admin-utc-offset');
            if (serverOffset !== undefined) {
            if (serverOffset) {
                var localOffset = new Date().getTimezoneOffset() * -60;
                DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
            }
@@ -43,7 +43,7 @@
        now: function() {
            var body = document.getElementsByTagName('body')[0];
            var serverOffset = body.getAttribute('data-admin-utc-offset');
            if (serverOffset !== undefined) {
            if (serverOffset) {
                var localNow = new Date();
                var localOffset = localNow.getTimezoneOffset() * -60;
                localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset));
+4 −0
Original line number Diff line number Diff line
@@ -46,3 +46,7 @@ Bugfixes

* Fixed ``TypedChoiceField`` change detection with nullable fields
  (:ticket:`25942`).

* Fixed incorrect timezone warnings in custom admin templates that don't have
  a ``data-admin-utc-offset`` attribute in the ``body`` tag.
  (:ticket:`25845`).
+4 −0
Original line number Diff line number Diff line
@@ -16,4 +16,8 @@ test('init', function(assert) {
    assert.equal(shortcuts.length, 1);
    assert.equal(shortcuts.find('a:first').text(), 'Today');
    assert.equal(shortcuts.find('a:last .date-icon').length, 1);

    // To prevent incorrect timezone warnings on date/time widgets, timezoneOffset
    // should be 0 when a timezone offset isn't set in the HTML body attribute.
    assert.equal(DateTimeShortcuts.timezoneOffset, 0);
});