Superpowered to do lists. No signup required.
1import { alphabet, generateRandomString } from "oslo/crypto";
2
3export function generateId() {
4 return generateRandomString(10, alphabet("a-z", "0-9"));
5}
6
7export function formatSecondsToDuration(seconds: number = 0) {
8 let hours = Math.floor(seconds / 3600);
9 let minutes = Math.floor((seconds - (hours * 3600)) / 60);
10 seconds = seconds - (hours * 3600) - (minutes * 60);
11
12 // string ver.
13 let hrs, mins, secs;
14
15 if (hours < 10) { hrs = "0" + hours; } else { hrs = hours; }
16 if (minutes < 10) { mins = "0" + minutes; } else { mins = minutes; }
17 if (seconds < 10) { secs = "0" + seconds; } else { secs = seconds; }
18
19 return hrs + ':' + mins + ':' + secs ;
20}