export enum { number } export enum durations { nano = 1e-6 , second = 1000 , minute = second * 60 , hour = minute * 60 , day = hour * 24 , thirtyDays = day * 30 } export const timeFormat = 'ddd dd/mm/yyyy HH:MM:ss' ; param { number } timestamp0 param { number } timestamp1 param { ( number | durations ) } duration returns export function getDurationDiff ( timestamp0 , timestamp1 , duration ) { return Math . abs ( timestamp0 - timestamp1 ) / duration ; } export param { number } timestamp0 param { number } timestamp1 returns export function getDayDiff ( timestamp0 , timestamp1 ) { return Math . round ( getDurationDiff ( timestamp0 , timestamp1 , durations . day ) ) ; } export param { number } msDuration returns export function getDistributedDuration ( msDuration ) { msDuration = Math . abs ( msDuration ) ; let days = Math . floor ( msDuration / durations . day ) ; let hours = Math . floor ( msDuration / durations . hour ) % 24 ; let minutes = Math . floor ( msDuration / durations . minute ) % 60 ; let seconds = Math . floor ( msDuration / durations . second ) % 60 ; let milliseconds = msDuration % 1000 ; return { days , hours , minutes , seconds , milliseconds } ; } export returns export function toNano ( time ) { return ( time [ 0 ] * 1e9 + time [ 1 ] ) * durations . nano ; }