From 61941b6fc172933f425e8ba76bab444ab9b313e4 Mon Sep 17 00:00:00 2001 From: Vedran Karacic Date: Fri, 12 Dec 2025 10:04:19 +0100 Subject: 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. --- js_tests/admin/DateTimeShortcuts.test.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'js_tests/admin/DateTimeShortcuts.test.js') diff --git a/js_tests/admin/DateTimeShortcuts.test.js b/js_tests/admin/DateTimeShortcuts.test.js index 5c850ce7d2..28d07fb918 100644 --- a/js_tests/admin/DateTimeShortcuts.test.js +++ b/js_tests/admin/DateTimeShortcuts.test.js @@ -1,7 +1,15 @@ /* global QUnit, DateTimeShortcuts */ "use strict"; -QUnit.module("admin.DateTimeShortcuts"); +QUnit.module("admin.DateTimeShortcuts", { + afterEach: function () { + const $ = django.jQuery; + $("body") + .removeAttr("data-admin-server-timezone") + .removeAttr("data-admin-utc-offset"); + $(".timezonewarning").remove(); + }, +}); QUnit.test("init", function (assert) { const $ = django.jQuery; @@ -46,11 +54,13 @@ QUnit.test("time zone offset warning - single field", function (assert) { "data-admin-utc-offset", new Date().getTimezoneOffset() * -60 + 3600, ); + $("body").attr("data-admin-server-timezone", "America/Chicago"); DateTimeShortcuts.init(); $("body").attr("data-admin-utc-offset", savedOffset); assert.equal( $(".timezonewarning").text(), - "Note: You are 1 hour behind server time.", + "Note: Enter times in the America/Chicago timezone. " + + "(You are 1 hour behind.)", ); assert.equal( $(".timezonewarning").attr("id"), @@ -74,6 +84,10 @@ QUnit.test("time zone offset warning - date and time field", function (assert) { ); DateTimeShortcuts.init(); $("body").attr("data-admin-utc-offset", savedOffset); + assert.equal( + $(".timezonewarning").text(), + "Note: Enter times in the server timezone. (You are 1 hour behind.)", + ); assert.equal( $(".timezonewarning").attr("id"), "id_updated_at_timezone_warning_helptext", -- cgit v1.3