import moment from 'moment' ; import { parseInterval } from '../../../../../src/plugins/data/common' ; export function getOffsetInMs ( { start , end , offset , } ) { if ( ! offset ) { return { startWithOffset : start , endWithOffset : end , offsetInMs : 0 , } ; } const interval = parseInterval ( offset ) ; if ( ! interval ) { throw new Error ( `Could not parse offset: ${ offset }` ) ; } const calculatedOffset = start - moment ( start ) . subtract ( interval ) . valueOf ( ) ; return { startWithOffset : start - calculatedOffset , endWithOffset : end - calculatedOffset , offsetInMs : calculatedOffset , } ; }