From 85fa3b767171c9e13bcbd48036ad9be6f453680d Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 8 Aug 2024 13:47:25 +0200 Subject: [PATCH] add time to recent earnings --- src/routes/home/+page.svelte | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/routes/home/+page.svelte b/src/routes/home/+page.svelte index e2c885ba..60037c60 100644 --- a/src/routes/home/+page.svelte +++ b/src/routes/home/+page.svelte @@ -39,6 +39,21 @@ return 0; } +function formatTime(timeString) { + // Split the time string into components + const [hours, minutes, seconds] = timeString.split(':').map(Number); + + // Determine AM or PM + const period = hours >= 12 ? 'PM' : 'AM'; + + // Convert hours from 24-hour to 12-hour format + const formattedHours = hours % 12 || 12; // Converts 0 to 12 for midnight + + // Format the time string + const formattedTimeString = `${formattedHours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')} ${period}`; + + return formattedTimeString; +} function reformatDate(dateString) { return dateString.substring(5, 7) + '/' + dateString.substring(8) + '/' + dateString.substring(2, 4); @@ -403,7 +418,7 @@ onMount( async() => {