import dateMath from '@elastic/datemath' ; import { formatDate } from '@elastic/eui' ; import { TimeRange } from '../../../../../src/plugins/data/common' ; import { TIME_FORMAT } from '../constants/time_format' ; export function formatHumanReadableDate ( ts ) { return formatDate ( ts , 'MMMM Do YYYY' ) ; } export function formatHumanReadableDateTime ( ts ) { return formatDate ( ts , 'MMMM Do YYYY, HH:mm' ) ; } export function formatHumanReadableDateTimeSeconds ( ts ) { return formatDate ( ts , 'MMMM Do YYYY, HH:mm:ss' ) ; } export function validateTimeRange ( time ? ) { if ( ! time ) return false ; const momentDateFrom = dateMath . parse ( time . from ) ; const momentDateTo = dateMath . parse ( time . to ) ; return ! ! ( momentDateFrom && momentDateFrom . isValid ( ) && momentDateTo && momentDateTo . isValid ( ) ) ; } export const timeFormatter = ( value ) => { return formatDate ( value , TIME_FORMAT ) ; } ;