import datemath from '@elastic/datemath' ; export function getAbsoluteTime ( range , opts = { } ) { const parsed = datemath . parse ( range , opts ) ; if ( parsed ) { return parsed . valueOf ( ) ; } } export function getAbsoluteDateRange ( { rangeFrom , rangeTo , } ) { if ( ! rangeFrom || ! rangeTo ) { return { start : undefined , end : undefined } ; } const absoluteStart = getAbsoluteTime ( rangeFrom ) ; const absoluteEnd = getAbsoluteTime ( rangeTo , { roundUp : true } ) ; if ( ! absoluteStart || ! absoluteEnd ) { throw new Error ( 'Could not parse date range' ) ; } return { start : new Date ( absoluteStart ) . toISOString ( ) , end : new Date ( absoluteEnd ) . toISOString ( ) , } ; }