mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Timerange: Fixes a bug where custom time ranges didn't respect UTC (#18217)
* Timerange: Fixes a bug where custom timeranges didn't respect UTC Closes #18170 Closes #18178
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Libaries
|
||||
import React, { Component } from 'react';
|
||||
import { toUtc } from '@grafana/data';
|
||||
import { toUtc, dateMath } from '@grafana/data';
|
||||
|
||||
// Types
|
||||
import { DashboardModel } from '../../state';
|
||||
@@ -61,9 +61,11 @@ export class DashNavTimeControls extends Component<Props> {
|
||||
const panel = dashboard.timepicker;
|
||||
const hasDelay = panel.nowDelay && timeRange.raw.to === 'now';
|
||||
|
||||
const adjustedFrom = dateMath.isMathString(timeRange.raw.from) ? timeRange.raw.from : timeRange.from;
|
||||
const adjustedTo = dateMath.isMathString(timeRange.raw.to) ? timeRange.raw.to : timeRange.to;
|
||||
const nextRange = {
|
||||
from: timeRange.raw.from,
|
||||
to: hasDelay ? 'now-' + panel.nowDelay : timeRange.raw.to,
|
||||
from: adjustedFrom,
|
||||
to: hasDelay ? 'now-' + panel.nowDelay : adjustedTo,
|
||||
};
|
||||
|
||||
this.timeSrv.setTime(nextRange);
|
||||
|
||||
Reference in New Issue
Block a user