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:
kay delaney
2019-07-24 11:00:36 +01:00
committed by GitHub
parent 1e5fc76601
commit 0752a09f92
3 changed files with 28 additions and 5 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);