export const getDayDiff = ( date1 , date2 ) : number => { return Math . ceil ( ( date2 . getTime ( ) - date1 . getTime ( ) ) / ( 1000 * 60 * 60 * 24 ) ) ; } ; export const getDayOffset = ( date , offset ) : Date => { const newDate = new Date ( date ) ; newDate . setDate ( newDate . getDate ( ) + offset ) ; return newDate ; } ; export const getEpochSecondForDay = ( date ) : number => { return Math . ceil ( date . getTime ( ) / ( 1000 * 60 * 60 * 24 ) ) * 60 * 60 * 24 ; } ; export const getWeekDiff = ( date1 , date2 ) : number => { return Math . ceil ( ( date2 . getTime ( ) - date1 . getTime ( ) ) / ( 1000 * 60 * 60 * 24 * 7 ) ) ; } ; export const getTimeEpoch = ( ) : number => { return Math . ceil ( new Date ( ) . getTime ( ) / ( 1000 * 60 * 60 * 24 ) ) * 60 * 60 * 24 ; } ; export const formatDate = ( date ) : string => { return `${ date . getFullYear ( ) }-${ date . getMonth ( ) + 1 }-${ date . getDate ( ) }` ; } ; export const dateFromEpoch = ( epoch ) : Date => { const date = new Date ( ) ; date . setTime ( epoch * 1000 ) ; return date ; } ;