diff --git a/src/lib/stores.svelte.ts b/src/lib/stores.svelte.ts index fdc1801..96d2bfd 100644 --- a/src/lib/stores.svelte.ts +++ b/src/lib/stores.svelte.ts @@ -35,6 +35,9 @@ export type Task = { id: string; description: string; is_completed: boolean; + // optional + duration?: number; + stopwatchInterval?: number; } export type List = { @@ -59,3 +62,18 @@ export const pinned_list = persisted("pinned_list", local_lists.value![0 export function generateId() { return generateRandomString(10, alphabet("a-z", "0-9")); } + +export function formatSecondsToDuration(seconds: number = 0) { + let hours = Math.floor(seconds / 3600); + let minutes = Math.floor((seconds - (hours * 3600)) / 60); + seconds = seconds - (hours * 3600) - (minutes * 60); + + // string ver. + let hrs, mins, secs; + + if (hours < 10) { hrs = "0" + hours; } else { hrs = hours; } + if (minutes < 10) { mins = "0" + minutes; } else { mins = minutes; } + if (seconds < 10) { secs = "0" + seconds; } else { secs = seconds; } + + return hrs + ':' + mins + ':' + secs ; +} diff --git a/src/routes/[id]/+page.svelte b/src/routes/[id]/+page.svelte index 0f9d30a..bf96091 100644 --- a/src/routes/[id]/+page.svelte +++ b/src/routes/[id]/+page.svelte @@ -1,8 +1,9 @@
@@ -122,12 +157,14 @@ {/if} - + + +