initial index
This commit is contained in:
parent
62cc828d6a
commit
88015a98cd
21 changed files with 343 additions and 56 deletions
|
@ -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`;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue