import moment from 'moment' ; import { IBucketAggConfig } from '../bucket_agg_type' ; import { DateRangeKey } from '../lib/date_range' ; import { buildRangeFilter , RangeFilterParams } from '../../../../../common' ; export const createFilterDateRange = ( agg , { from , to } ) => { const filter = { } ; if ( from ) filter . gte = moment ( from ) . toISOString ( ) ; if ( to ) filter . lt = moment ( to ) . toISOString ( ) ; if ( to && from ) filter . format = 'strict_date_optional_time' ; return buildRangeFilter ( agg . params . field , filter , agg . getIndexPattern ( ) ) ; } ;