import dayjs from 'dayjs' ; import customParsing from 'dayjs/plugin/customParseFormat' ; dayjs . extend ( customParsing ) ; export const createOnChangeHandler = ( path , handleChange , saveFormat ) => ( time ) => { if ( ! time ) { handleChange ( path , undefined ) ; return ; } const result = dayjs ( time ) . format ( saveFormat ) ; handleChange ( path , result === 'Invalid Date' ? undefined : result ) ; } ; export const getData = ( data , saveFormat ) : dayjs . Dayjs | null => { if ( ! data ) { return null ; } const dayjsData = dayjs ( data , saveFormat ) ; if ( dayjsData . toString ( ) === 'Invalid Date' ) { return null ; } return dayjsData ; } ;