diff --git a/src/lib/components/Options/GreekExposure.svelte b/src/lib/components/Options/GreekExposure.svelte index 5772a094..024d5aca 100644 --- a/src/lib/components/Options/GreekExposure.svelte +++ b/src/lib/components/Options/GreekExposure.svelte @@ -225,24 +225,20 @@ } function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } async function handleScroll() { diff --git a/src/lib/components/Options/UnusualActivity.svelte b/src/lib/components/Options/UnusualActivity.svelte index ab7f5069..479011e2 100644 --- a/src/lib/components/Options/UnusualActivity.svelte +++ b/src/lib/components/Options/UnusualActivity.svelte @@ -73,26 +73,21 @@ } function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } - function getScroll() { const scrollThreshold = container.scrollHeight * 0.8; // 80% of the container height diff --git a/src/lib/components/Options/Volatility.svelte b/src/lib/components/Options/Volatility.svelte index 330acaab..f3139c7e 100644 --- a/src/lib/components/Options/Volatility.svelte +++ b/src/lib/components/Options/Volatility.svelte @@ -249,24 +249,20 @@ } function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } async function handleScroll() { diff --git a/src/routes/etf/[tickerID]/options/+page.svelte b/src/routes/etf/[tickerID]/options/+page.svelte index bedb4724..61bce5ba 100644 --- a/src/routes/etf/[tickerID]/options/+page.svelte +++ b/src/routes/etf/[tickerID]/options/+page.svelte @@ -39,26 +39,21 @@ let displayTimePeriod = "oneYear"; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } - function changeVolumeOI(event) { displayData = event.target.value; } diff --git a/src/routes/etf/[tickerID]/options/hottest-contracts/+page.svelte b/src/routes/etf/[tickerID]/options/hottest-contracts/+page.svelte index 112ceaf2..3d3b3886 100644 --- a/src/routes/etf/[tickerID]/options/hottest-contracts/+page.svelte +++ b/src/routes/etf/[tickerID]/options/hottest-contracts/+page.svelte @@ -51,24 +51,20 @@ let otmPercentage; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } function computeOTM(strikePrice, optionType) { diff --git a/src/routes/index/[tickerID]/options/+page.svelte b/src/routes/index/[tickerID]/options/+page.svelte index a16a205e..cd7d75f0 100644 --- a/src/routes/index/[tickerID]/options/+page.svelte +++ b/src/routes/index/[tickerID]/options/+page.svelte @@ -36,24 +36,20 @@ let displayTimePeriod = "oneYear"; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } function changeVolumeOI(event) { diff --git a/src/routes/index/[tickerID]/options/hottest-contracts/+page.svelte b/src/routes/index/[tickerID]/options/hottest-contracts/+page.svelte index e5461ba1..c6bafdcb 100644 --- a/src/routes/index/[tickerID]/options/hottest-contracts/+page.svelte +++ b/src/routes/index/[tickerID]/options/hottest-contracts/+page.svelte @@ -51,24 +51,20 @@ let otmPercentage; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } function computeOTM(strikePrice, optionType) { diff --git a/src/routes/stocks/[tickerID]/options/+page.svelte b/src/routes/stocks/[tickerID]/options/+page.svelte index 8dd132d9..a3c5d2ee 100644 --- a/src/routes/stocks/[tickerID]/options/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/+page.svelte @@ -39,24 +39,20 @@ let displayTimePeriod = "oneYear"; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } function changeVolumeOI(event) { diff --git a/src/routes/stocks/[tickerID]/options/hottest-contracts/+page.svelte b/src/routes/stocks/[tickerID]/options/hottest-contracts/+page.svelte index 5627475e..f2c74e91 100644 --- a/src/routes/stocks/[tickerID]/options/hottest-contracts/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/hottest-contracts/+page.svelte @@ -51,24 +51,20 @@ let otmPercentage; function formatDate(dateStr) { - // Parse the input date string (YYYY-mm-dd) - var date = new Date(dateStr); + // Convert the input date string to a Date object in New York time + let date = new Date(dateStr + "T00:00:00Z"); // Assume input is in UTC - // Get month, day, and year - var month = date.getMonth() + 1; // Month starts from 0 - var day = date.getDate(); - var year = date.getFullYear(); + // Convert to New York Time Zone + let options = { + timeZone: "Europe/Berlin", + month: "2-digit", + day: "2-digit", + year: "2-digit", + }; - // Extract the last two digits of the year - var shortYear = year.toString().slice(-2); + let formatter = new Intl.DateTimeFormat("en-US", options); - // Add leading zeros if necessary - month = (month < 10 ? "0" : "") + month; - day = (day < 10 ? "0" : "") + day; - - var formattedDate = month + "/" + day + "/" + year; - - return formattedDate; + return formatter.format(date); } function computeOTM(strikePrice, optionType) {