Timerange: Fixes a bug where custom time ranges didn't respect UTC (#18248)

Closes #18170
Closes #18178
This commit is contained in:
kay delaney
2019-07-24 14:09:52 +01:00
committed by David
parent 459769af70
commit c01bbf2058
3 changed files with 29 additions and 6 deletions

View File

@@ -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);