initial index

This commit is contained in:
41666 2023-05-22 21:04:29 -04:00
parent 62cc828d6a
commit 88015a98cd
21 changed files with 343 additions and 56 deletions

View file

@ -7,3 +7,24 @@ export const toTitleCase = (str: string) => {
export const pascalCaseToTitleCase = (str: string) => {
return toTitleCase(str.replace(/([A-Z])/g, " $1"));
};
export const humanTimeAgo = (ms: number) => {
const millis = Math.floor(ms % 1000);
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
if (hours > 0) {
return `${hours}h`;
}
if (minutes > 0) {
return `${minutes}m`;
}
if (seconds > 0) {
return `${seconds}s`;
}
return `${millis}ms`;
};