import moment from 'moment' ; import { TimeRangeComparisonEnum } from '../../../../common/runtime_types/comparison_type_rt' ; import { getDateDifference } from '../../../../common/utils/formatters' ; export function getComparisonTypes ( { start , end , } ) { const momentStart = moment ( start ) . startOf ( 'second' ) ; const momentEnd = moment ( end ) . startOf ( 'second' ) ; const dateDiff = getDateDifference ( { start : momentStart , end : momentEnd , precise : true , unitOfTime : 'days' , } ) ; if ( dateDiff <= 1 ) { return [ TimeRangeComparisonEnum . DayBefore , TimeRangeComparisonEnum . WeekBefore , ] ; } if ( dateDiff <= 7 ) { return [ TimeRangeComparisonEnum . WeekBefore ] ; } return [ TimeRangeComparisonEnum . PeriodBefore ] ; }