Skip to content

Commit 4b5b738

Browse files
Time Zones: Fix relative time when using UTC timezone (#85637)
add UTC case to e2e test + let UTC pass through to moment.tz
1 parent 8d75dce commit 4b5b738

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

e2e/dashboards-suite/dashboard-time-zone.spec.ts

+35
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,41 @@ describe('Dashboard time zone support', () => {
112112
// Need to wait for 2 calls as there's 2 panels
113113
cy.wait(['@dataQuery', '@dataQuery']);
114114

115+
e2e.components.Panels.Panel.title('Panel with relative time override')
116+
.should('be.visible')
117+
.within(() => {
118+
cy.contains('[role="row"]', '00:00:00').should('be.visible');
119+
});
120+
121+
e2e.components.Panels.Panel.title('Panel in timezone')
122+
.should('be.visible')
123+
.within(() => {
124+
cy.contains('[role="row"]', '00:00:00').should('be.visible');
125+
});
126+
127+
// Test UTC timezone
128+
e2e.flows.setTimeRange({
129+
from: 'now-6h',
130+
to: 'now',
131+
zone: 'Coordinated Universal Time',
132+
});
133+
// Need to wait for 2 calls as there's 2 panels
134+
cy.wait(['@dataQuery', '@dataQuery']);
135+
136+
e2e.components.Panels.Panel.title('Panel with relative time override')
137+
.should('be.visible')
138+
.within(() => {
139+
cy.contains('[role="row"]', '00:00:00').should('be.visible');
140+
});
141+
142+
// Today so far, still in UTC timezone
143+
e2e.flows.setTimeRange({
144+
from: 'now/d',
145+
to: 'now',
146+
});
147+
// Need to wait for 2 calls as there's 2 panels
148+
cy.wait(['@dataQuery', '@dataQuery']);
149+
115150
e2e.components.Panels.Panel.title('Panel with relative time override')
116151
.should('be.visible')
117152
.within(() => {

packages/grafana-data/src/datetime/moment_wrapper.ts

-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ export const dateTimeForTimeZone = (
126126
input?: DateTimeInput,
127127
formatInput?: FormatInput
128128
): DateTime => {
129-
if (timezone === 'utc') {
130-
return toUtc(input, formatInput);
131-
}
132-
133129
if (timezone && timezone !== 'browser') {
134130
let result: moment.Moment;
135131

0 commit comments

Comments
 (0)