param date return function cloneDate ( date ) { return new Date ( date . getTime ( ) ) ; } param date param amount return export function subDays ( date , amount ) { const newDate = cloneDate ( date ) ; newDate . setDate ( newDate . getDate ( ) - amount ) ; return newDate ; } param date param amount return export function subMonths ( date , amount ) { const newDate = cloneDate ( date ) ; newDate . setMonth ( newDate . getMonth ( ) - amount ) ; return newDate ; } param lDate param rDate returns export function isSameDay ( lDate , rDate ) { return getStartOfDay ( lDate ) . getTime ( ) === getStartOfDay ( rDate ) . getTime ( ) ; } param lDate param rDate returns export function getDaysBetween ( lDate , rDate ) { return Math . abs ( Math . floor ( ( getNormalizedUTCDate ( lDate ) - getNormalizedUTCDate ( rDate ) ) / ( 1000 * 60 * 60 * 24 ) ) ) ; } param date returns function getStartOfDay ( date ) { const startOfDay = cloneDate ( date ) ; startOfDay . setHours ( 0 , 0 , 0 , 0 ) ; return startOfDay ; } param date returns function getNormalizedUTCDate ( date ) { return Date . UTC ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) ) ; }