diff --git a/src/lib/components/WIIM.svelte b/src/lib/components/WIIM.svelte index aa8d1de4..7abc496a 100644 --- a/src/lib/components/WIIM.svelte +++ b/src/lib/components/WIIM.svelte @@ -11,11 +11,19 @@ let showFullHistory = false; function latestInfoDate(inputDate) { - // Convert the input date string to milliseconds since epoch - const inputDateMs = new Date(inputDate); + // Create a Date object for the input date and convert it to New York time zone + const inputDateLocal = new Date(inputDate).toLocaleString("en-US", { + timeZone: "America/New_York", + }); - // Get today's date in milliseconds since epoch - const todayMs = Date.now(); + // Get the current date and time in New York timezone + const todayLocal = new Date().toLocaleString("en-US", { + timeZone: "America/New_York", + }); + + // Convert the localized strings back to Date objects + const inputDateMs = new Date(inputDateLocal).getTime(); + const todayMs = new Date(todayLocal).getTime(); // Calculate the difference in milliseconds const differenceInMs = todayMs - inputDateMs; @@ -23,7 +31,7 @@ // Convert milliseconds to days const differenceInDays = Math.floor(differenceInMs / (1000 * 60 * 60 * 24)); - // Return the difference in days + // Return whether the difference is less than or equal to 1 day return differenceInDays <= 1; } diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 6ff3bce0..d675a7f3 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -671,7 +671,14 @@ export function abbreviateNumber(number, addDollarSign = false) { export const formatDate = (dateString) => { const date = new Date(dateString); - const now = new Date(); + + // Get the current time in New York timezone + const now = new Date( + new Intl.DateTimeFormat("en-US", { + timeZone: "America/New_York", + }).format(new Date()) + ); + const diffInDays = Math.floor((now - date) / (1000 * 60 * 60 * 24)); if (diffInDays >= 30) { diff --git a/src/routes/stocks/[tickerID]/profile/+page.server.ts b/src/routes/stocks/[tickerID]/profile/+page.server.ts index 191e625e..71f53b89 100644 --- a/src/routes/stocks/[tickerID]/profile/+page.server.ts +++ b/src/routes/stocks/[tickerID]/profile/+page.server.ts @@ -4,7 +4,7 @@ import { loginUserSchema, registerUserSchema } from "$lib/schemas"; export const load = async ({ params, locals }) => { - const getStockDividend = async () => { + const getData = async () => { let newsList; const { apiURL, apiKey } = locals; @@ -14,7 +14,7 @@ export const load = async ({ params, locals }) => { }; // make the POST request to the endpoint - const response = await fetch(apiURL + "/stock-dividend", { + const response = await fetch(apiURL + "/profile", { method: "POST", headers: { "Content-Type": "application/json", @@ -30,7 +30,7 @@ export const load = async ({ params, locals }) => { // Make sure to return a promise return { - getStockDividend: await getStockDividend(), + getData: await getData(), }; }; diff --git a/src/routes/stocks/[tickerID]/profile/+page.svelte b/src/routes/stocks/[tickerID]/profile/+page.svelte index e66773d3..04c709b2 100644 --- a/src/routes/stocks/[tickerID]/profile/+page.svelte +++ b/src/routes/stocks/[tickerID]/profile/+page.svelte @@ -4,11 +4,42 @@ displayCompanyName, numberOfUnreadNotification, } from "$lib/store"; + import { sectorNavigation } from "$lib/utils"; export let data; - const similarStocks = data?.getSimilarStocks?.sort( - (a, b) => b?.dividendYield - a?.dividendYield, + const rawData = data?.getData; + + function getIndustryHref(industryName) { + // Replace spaces with hyphens + let formattedName = industryName?.replace(/ /g, "-"); + // Replace "&" with "and" + formattedName = formattedName?.replace(/&/g, "and"); + // Remove any extra hyphens (e.g., from consecutive spaces) + formattedName = formattedName?.replace(/-{2,}/g, "-"); + // Convert to lowercase for consistency + return "/list/industry/" + formattedName?.toLowerCase(); + } + + function textToParagraphs(text) { + // Split the text into sentences + const sentences = text.split( + /(? `
${sentence.trim()}
`, + ); + + // Wrap paragraphs in a div with additional classes + return `- The Coca-Cola Company, a beverage company, manufactures, - markets, and sells various nonalcoholic beverages worldwide. -
-- The company provides sparkling soft drinks, sparkling flavors; - water, sports, coffee, and tea; juice, value-added dairy, and - plant-based beverages; and other beverages. -
-- It also offers beverage concentrates and syrups, as well as - fountain syrups to fountain retailers, such as restaurants and - convenience stores. -
-- The company sells its products under the Coca-Cola, Diet - Coke/Coca-Cola Light, Coca-Cola Zero Sugar, caffeine free Diet - Coke, Cherry Coke, Fanta Orange, Fanta Zero Orange, Fanta Zero - Sugar, Fanta Apple, Sprite, Sprite Zero Sugar, Simply Orange, - Simply Apple, Simply Grapefruit, Fresca, Schweppes, Thums Up, - Aquarius, Ayataka, BODYARMOR, Ciel, Costa, Dasani, doğadan, FUZE - TEA, Georgia, glacéau smartwater, glacéau vitaminwater, Gold - Peak, Ice Dew, I LOHAS, Powerade, Topo Chico, AdeS, Del Valle, - fairlife, innocent, Minute Maid, and Minute Maid Pulpy brands. -
-- It operates through a network of independent bottling partners, - distributors, wholesalers, and retailers, as well as through - bottling and distribution operators. -
-- The company was founded in 1886 and is headquartered in Atlanta, - Georgia. -
-| Name | -Position |
|---|---|
| James Robert B. Quincey | -Chairman and Chief Executive Officer | -
| John Murphy | -President and Chief Financial Officer | -
| Manuel Arroyo Prieto | -Executive Vice President and Global chief Marketing Officer | -
| Henrique Braun | -Executive Vice President and President of International - Development | -
| Jennifer Kay Mann | -Executive Vice President and President of North America - Operating Unit | -
| Erin May | -Senior Vice President, Chief Accounting Officer and - Controller | -
| Stacy Lynn Apter | -Senior Vice President, Treasurer and Head of Corporate - Finance | -
| Nancy W. Quan | -Executive Vice President and Global Chief Technical and - Innovation Officer | -
| Neeraj Tolmare | -Senior Vice President and Chief Information Officer | -
| Robin Halpern | -Vice President and Head of Investor Relations | -
| Name | +Position |
|---|---|
| {item?.name} | +{item?.position} | +
| Date | -Type | -Title |
|---|---|---|
| Dec 11, 2024 | -8-K | -Current Report | -
| Nov 27, 2024 | -144 | -Filing | -
| Nov 7, 2024 | -144 | -Filing | -
| Oct 24, 2024 | -10-Q | -Quarterly Report | -
| Oct 23, 2024 | -8-K | -Current Report | -
| Oct 17, 2024 | -8-K | -Current Report | -
| Aug 26, 2024 | -144 | -Filing | -
| Aug 21, 2024 | -8-K | -Current Report | -
| Aug 21, 2024 | -144 | -Filing | -
| Aug 21, 2024 | -144 | -Filing | -
| Date | +Type | +Title |
|---|---|---|
| {item?.date} | +{item?.type} | +{item?.title?.length > 50 + ? item?.title?.slice(0, 50) + "..." + : item?.title} | +