22 lines
636 B
TypeScript
22 lines
636 B
TypeScript
export function convertCamelCaseToReadable(camelCaseString: string): string {
|
|
// Split the string using regex to match the capital letters
|
|
const wordsArray = camelCaseString.split(/(?=[A-Z])/);
|
|
|
|
// Capitalize the first letter of each word and join the words with a space
|
|
const readableString = wordsArray.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
|
|
return readableString;
|
|
}
|
|
|
|
export function formatTimeInMinutes(time: number) {
|
|
if (time === 0) {
|
|
return "00:00";
|
|
}
|
|
|
|
return `${Math.floor(time / 60)
|
|
.toString(10)
|
|
.padStart(2, "0")}:${Math.floor(time % 60)
|
|
.toString(10)
|
|
.padStart(2, "0")}`;
|
|
}
|