import { compareDesc , differenceInMilliseconds , subMinutes } from "date-fns/fp" ; export const timeExceedRedundancyOneMinute = ( time ) : boolean => { const redundancyTime = subMinutes ( 1 ) ( Date . now ( ) ) ; return compareDesc ( time ) ( redundancyTime ) === - 1 ; } ; export const beginTimeLessEndTime = ( beginTime , endTime ) : boolean => { return compareDesc ( endTime ) ( beginTime ) === - 1 ; } ; const timeIntervalLessThanOrEqualMinute = ( beginTime , endTime , minute ) : boolean => { return differenceInMilliseconds ( beginTime , endTime ) < minute ; } ; export const timeIntervalLessThanFifteenMinute = ( beginTime , endTime ) : boolean => { return timeIntervalLessThanOrEqualMinute ( beginTime , endTime , 1000 * 60 * 15 ) ; } ; export const checkBeginAndEndTime = ( beginTime , endTime ) : boolean => { if ( timeExceedRedundancyOneMinute ( beginTime ) ) { return false ; } if ( beginTimeLessEndTime ( beginTime , endTime ) ) { return false ; } if ( timeIntervalLessThanFifteenMinute ( beginTime , endTime ) ) { return false ; } return true ; } ;