Skip to content

Commit

Permalink
Time Zones: Fix relative time when using UTC timezone (#85637)
Browse files Browse the repository at this point in the history
add UTC case to e2e test + let UTC pass through to moment.tz
  • Loading branch information
ashharrison90 authored Apr 9, 2024
1 parent 8d75dce commit 4b5b738
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
35 changes: 35 additions & 0 deletions e2e/dashboards-suite/dashboard-time-zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,41 @@ describe('Dashboard time zone support', () => {
// Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']);

e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});

e2e.components.Panels.Panel.title('Panel in timezone')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});

// Test UTC timezone
e2e.flows.setTimeRange({
from: 'now-6h',
to: 'now',
zone: 'Coordinated Universal Time',
});
// Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']);

e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible')
.within(() => {
cy.contains('[role="row"]', '00:00:00').should('be.visible');
});

// Today so far, still in UTC timezone
e2e.flows.setTimeRange({
from: 'now/d',
to: 'now',
});
// Need to wait for 2 calls as there's 2 panels
cy.wait(['@dataQuery', '@dataQuery']);

e2e.components.Panels.Panel.title('Panel with relative time override')
.should('be.visible')
.within(() => {
Expand Down
4 changes: 0 additions & 4 deletions packages/grafana-data/src/datetime/moment_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ export const dateTimeForTimeZone = (
input?: DateTimeInput,
formatInput?: FormatInput
): DateTime => {
if (timezone === 'utc') {
return toUtc(input, formatInput);
}

if (timezone && timezone !== 'browser') {
let result: moment.Moment;

Expand Down

0 comments on commit 4b5b738

Please sign in to comment.