From 5c051bac0c88e4e63dd30df7a6dac3fbf2102e15 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 12 Jul 2024 12:08:15 +0200 Subject: [PATCH] ui fix --- src/routes/dark-pool-flow/+page.svelte | 26 +++++++++++++++-------- src/routes/options-flow/+page.svelte | 23 ++++++++++++++++---- src/routes/options-zero-dte/+page.svelte | 27 +++++++++++++++++++----- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/src/routes/dark-pool-flow/+page.svelte b/src/routes/dark-pool-flow/+page.svelte index ab6b5eb0..d6f10eb9 100644 --- a/src/routes/dark-pool-flow/+page.svelte +++ b/src/routes/dark-pool-flow/+page.svelte @@ -30,8 +30,7 @@ function getLastDate(dateString) { // Check if it is a weekday (Monday to Friday) if (dayOfWeek >= 1 && dayOfWeek <= 5) { - // Subtract one day - date.setDate(date.getDate() - 1); + date.setDate(date.getDate()); } else { // Find the last weekday of the week // If it's Saturday, go back to Friday @@ -46,19 +45,28 @@ function getLastDate(dateString) { return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); } } - function formatTime(dateString) { - // Parse the date string to a Date object +function formatTime(dateString) { + // Parse the date string to a Date object const date = new Date(dateString); // Extract hours, minutes, and seconds - const hours = String(date.getUTCHours()).padStart(2, '0'); + let hours = date.getUTCHours(); const minutes = String(date.getUTCMinutes()).padStart(2, '0'); const seconds = String(date.getUTCSeconds()).padStart(2, '0'); - // Format time as hh:mm:ss - return `${hours}:${minutes}:${seconds}`; + // Determine AM/PM + const ampm = hours >= 12 ? 'PM' : 'AM'; - } + // Convert hours from 24-hour to 12-hour format + hours = hours % 12; + hours = hours ? hours : 12; // the hour '0' should be '12' + + // Format hours + const formattedHours = String(hours).padStart(2, '0'); + + // Format time as hh:mm:ss AM/PM + return `${formattedHours}:${minutes}:${seconds} ${ampm}`; +} function findMostFrequentTicker(data) { const tickerCountMap = new Map(); @@ -267,7 +275,7 @@ function getLastDate(dateString) { - Live Flow of {displayDate} + Live Flow of {displayDate} (NYSE Time) diff --git a/src/routes/options-flow/+page.svelte b/src/routes/options-flow/+page.svelte index 7b711733..5f37932b 100644 --- a/src/routes/options-flow/+page.svelte +++ b/src/routes/options-flow/+page.svelte @@ -81,7 +81,22 @@ } - + 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')}:${seconds.toString().padStart(2, '0')} ${period}`; + + return formattedTimeString; +} + function handleViewData(optionData) { //optionStart = optionData['Start Date'] === null ? 'n/a' : new Date(optionData['Start Date'])?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' }); optionSymbol = optionData?.option_symbol; @@ -555,8 +570,8 @@ $: {
{#if !$isOpen} - - Live flow of {new Date(optionList?.at(0)?.date ?? null)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} + + Live flow of {new Date(optionList?.at(0)?.date ?? null)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} (NYSE Time) {/if} @@ -858,7 +873,7 @@ $: { handleViewData(item)} class="w-full odd:bg-[#202020] cursor-pointer {index+1 === optionList?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}"> - {item?.time} + {formatTime(item?.time)} assetSelector(item?.ticker, item?.assetType)} class="{index % 2 ? 'bg-[#0F0F0F]' : 'bg-[#202020]'} text-blue-400 text-start font-normal"> diff --git a/src/routes/options-zero-dte/+page.svelte b/src/routes/options-zero-dte/+page.svelte index 9a6a2907..cfa55dcb 100644 --- a/src/routes/options-zero-dte/+page.svelte +++ b/src/routes/options-zero-dte/+page.svelte @@ -72,6 +72,23 @@ function toggleMode() } +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')}:${seconds.toString().padStart(2, '0')} ${period}`; + + return formattedTimeString; +} + + function handleViewData(optionData) { //optionStart = optionData['Start Date'] === null ? 'n/a' : new Date(optionData['Start Date'])?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' }); optionSymbol = optionData?.option_symbol; @@ -453,8 +470,8 @@ const debouncedHandleInput = debounce(handleInput, 200);
{#if !$isOpen} - - Live flow of {new Date(optionList?.at(0)?.date ?? null)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} + + Live flow of {new Date(optionList?.at(0)?.date ?? null)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} (NYSE Time) {/if} @@ -745,9 +762,9 @@ const debouncedHandleInput = debounce(handleInput, 200); handleViewData(item)} class="w-full odd:bg-[#202020] cursor-pointer {index+1 === optionList?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}"> - - {item?.time} - + + {formatTime(item?.time)} + assetSelector(item?.ticker, item?.assetType)} class="{index % 2 ? 'bg-[#0F0F0F]' : 'bg-[#202020]'} text-blue-400 text-start font-normal"> {item?.ticker}