From 3ee925610aefbddf36104b758b3289d630eb9d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jamr=C3=B3z?= Date: Tue, 27 Apr 2021 09:55:22 +0200 Subject: [PATCH] Use either moment objects (for absolute times in the datepicker) or string (for relative time) (#33315) --- public/app/features/explore/ExploreTimeControls.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/app/features/explore/ExploreTimeControls.tsx b/public/app/features/explore/ExploreTimeControls.tsx index 26493f337ca..b20f42f490d 100644 --- a/public/app/features/explore/ExploreTimeControls.tsx +++ b/public/app/features/explore/ExploreTimeControls.tsx @@ -3,7 +3,7 @@ import React, { Component } from 'react'; // Types import { ExploreId } from 'app/types'; -import { TimeRange, TimeZone, RawTimeRange, dateTimeForTimeZone } from '@grafana/data'; +import { TimeRange, TimeZone, RawTimeRange, dateTimeForTimeZone, dateMath } from '@grafana/data'; // State @@ -42,7 +42,13 @@ export class ExploreTimeControls extends Component { onMoveBack = () => this.onMoveTimePicker(-1); onChangeTimePicker = (timeRange: TimeRange) => { - this.props.onChangeTime(timeRange.raw); + const adjustedFrom = dateMath.isMathString(timeRange.raw.from) ? timeRange.raw.from : timeRange.from; + const adjustedTo = dateMath.isMathString(timeRange.raw.to) ? timeRange.raw.to : timeRange.to; + + this.props.onChangeTime({ + from: adjustedFrom, + to: adjustedTo, + }); }; onZoom = () => {