import { intervalToDuration , Duration } from 'date-fns' ; import padStart from 'lodash/padStart' ; param duration returns export function formatDuration ( duration ) { const { days , hours , minutes , seconds } = duration ; const hoursWithDays = days != null ? days * 24 + ( hours ?? 0 ) : hours ; const paddedHours = padStart ( hoursWithDays ?. toString ( ) , 2 , '0' ) ; const paddedMinutes = padStart ( minutes ?. toString ( ) , 2 , '0' ) ; const paddedSeconds = padStart ( seconds ?. toString ( ) , 2 , '0' ) ; return `${ paddedHours }:${ paddedMinutes }:${ paddedSeconds }` ; } param start param end returns export function formatInterval ( start , end ) { const duration = intervalToDuration ( { start : new Date ( start ) , end : new Date ( end ) , } ) ; return formatDuration ( duration ) ; }