import moment from 'moment' ; import { keys } from 'lodash' ; import { TimefilterContract } from '../../timefilter' ; import { RangeFilter , TimeRange } from '../../../../common' ; export function convertRangeFilterToTimeRange ( filter ) { const key = keys ( filter . range ) [ 0 ] ; const values = filter . range [ key ] ; return { from : moment ( values . gt || values . gte ) , to : moment ( values . lt || values . lte ) , } ; } export function convertRangeFilterToTimeRangeString ( filter ) { const { from , to } = convertRangeFilterToTimeRange ( filter ) ; return { from : from ?. toISOString ( ) , to : to ?. toISOString ( ) , } ; } export function changeTimeFilter ( timeFilter , filter ) { timeFilter . setTime ( convertRangeFilterToTimeRange ( filter ) ) ; }