baseui
Version:
A React Component library implementing the Base design language
27 lines (24 loc) • 769 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatTime = void 0;
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
function padTo2Digits(num) {
return num.toString().padStart(2, '0');
}
const formatTime = totalMilliseconds => {
let totalSeconds = Math.floor(totalMilliseconds / 1000);
// If there are remaining milliseconds, consider it as an extra second.
if (totalMilliseconds % 1000 > 0) {
totalSeconds += 1;
}
const minutes = Math.floor(totalSeconds / 60);
const seconds = Math.floor(totalSeconds % 60);
return `${minutes}:${padTo2Digits(seconds)}`;
};
exports.formatTime = formatTime;