This commit is contained in:
MuslemRahimi 2024-07-12 20:26:16 +02:00
parent 3ce8796c17
commit 9d563d9ae1
2 changed files with 28 additions and 16 deletions

View File

@ -47,26 +47,23 @@ const putOpenInterestList = data?.getOptionsPlotData?.putOpenInterestList;
function formatTime(timestamp) { function formatTime(timeString) {
// Convert timestamp to milliseconds // Split the time string into components
var date = new Date(timestamp * 1000); const [hours, minutes, seconds] = timeString.split(':').map(Number);
// hours, minutes, and seconds // Determine AM or PM
var hours = date.getHours(); const period = hours >= 12 ? 'PM' : 'AM';
var minutes = date.getMinutes();
var seconds = date.getSeconds();
hours = (hours < 10 ? "0" : "") + hours; // Convert hours from 24-hour to 12-hour format
minutes = (minutes < 10 ? "0" : "") + minutes; const formattedHours = hours % 12 || 12; // Converts 0 to 12 for midnight
seconds = (seconds < 10 ? "0" : "") + seconds;
// Format the date string // Format the time string
var formattedDate = hours + ":" + minutes + ":" + seconds const formattedTimeString = `${formattedHours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} ${period}`;
//var formattedDate = hours + ":" + minutes + ":" + seconds;
return formattedDate; return formattedTimeString;
} }
function formatDate(dateStr) { function formatDate(dateStr) {
// Parse the input date string (YYYY-mm-dd) // Parse the input date string (YYYY-mm-dd)
var date = new Date(dateStr); var date = new Date(dateStr);
@ -530,7 +527,7 @@ $: {
<tr class="odd:bg-[#202020] border-b-[#0F0F0F] {index+1 === optionList?.slice(0,3)?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}"> <tr class="odd:bg-[#202020] border-b-[#0F0F0F] {index+1 === optionList?.slice(0,3)?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}">
<td class="text-white text-xs sm:text-sm text-start"> <td class="text-white text-xs sm:text-sm text-start">
{item?.time} {formatTime(item?.time)}
</td> </td>
<td class="text-white text-xs sm:text-sm text-start"> <td class="text-white text-xs sm:text-sm text-start">

View File

@ -68,6 +68,21 @@ function formatDate(dateStr) {
return formattedDate; return formattedDate;
} }
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 changeStatement(event) function changeStatement(event)
{ {
@ -509,7 +524,7 @@ $: {
<tr class="odd:bg-[#202020] border-b-[#0F0F0F] {index+1 === optionList?.slice(0,3)?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}"> <tr class="odd:bg-[#202020] border-b-[#0F0F0F] {index+1 === optionList?.slice(0,3)?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}">
<td class="text-white text-xs sm:text-sm text-start"> <td class="text-white text-xs sm:text-sm text-start">
{item?.time} {formatTime(item?.time)}
</td> </td>
<td class="text-white text-xs sm:text-sm text-start"> <td class="text-white text-xs sm:text-sm text-start">