From 48da635be22e4e01d71d62a957f3b4c0803a64de Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Mon, 25 Dec 2023 15:21:53 +0100 Subject: [PATCH] [JENKINS-71965] fix timezone in build history (#8800) * [JENKINS-71965] fix timezone in build history the timezone shown was always the daylight saving time when the users selected timezone has daylight saving. The change will now consider the actual timestamp of the build to determine if it was in daylight saving time to properly calculate the timezone to show. * make locale aware --- core/src/main/java/hudson/Functions.java | 4 ++-- .../main/resources/hudson/widgets/HistoryWidget/entry.jelly | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 0d5786815e..9cc4659ef3 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -692,13 +692,13 @@ public class Functions { } @Restricted(NoExternalUse.class) - public static String getUserTimeZonePostfix() { + public static String getUserTimeZonePostfix(Date date) { if (!isUserTimeZoneOverride()) { return ""; } TimeZone tz = TimeZone.getTimeZone(getUserTimeZone()); - return tz.getDisplayName(tz.observesDaylightTime(), TimeZone.SHORT); + return tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT, getCurrentLocale()); } @Restricted(NoExternalUse.class) diff --git a/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly b/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly index a774744766..31dbb322fb 100644 --- a/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly +++ b/core/src/main/resources/hudson/widgets/HistoryWidget/entry.jelly @@ -50,7 +50,7 @@ THE SOFTWARE. ${%Took} ${build.durationString} - ${h.getUserTimeZonePostfix()} + ${h.getUserTimeZonePostfix(build.timestamp.time)}