The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/lib/utils/secondsToHHMMSS.ts

14 lines
478 B

/**
* @todo check alternatives for date/time formatting
*/
export const secondsToHHMMSS = (sec: number | string): string => {
if (typeof sec !== 'number') {
sec = parseFloat(sec);
}
const hours = Math.floor(sec / 3600);
const minutes = Math.floor((sec - hours * 3600) / 60);
const seconds = Math.round(sec - hours * 3600 - minutes * 60);
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
};