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 `
+${paragraphs.join("\n")} +
`; + } + + const formattedText = textToParagraphs( + rawData?.description || "No Company description available at the moment.", ); @@ -59,48 +90,13 @@ class="relative flex flex-row justify-center items-start overflow-hidden w-full" >
-
+

Company Description

-
-

- 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. -

-
+ {@html formattedText}
-
+
@@ -121,30 +117,39 @@ class="px-1 py-1.5 font-semibold lg:py-2" data-svelte-h="svelte-bpivlp">Country - United States{rawData?.country + ? rawData?.country?.replace("US", "United States") + : "n/a"} - Founded 1886 + IPO Date - Sep 5, 1919{rawData?.ipoDate !== null && + rawData?.ipoDate?.length > 0 + ? new Date(rawData?.ipoDate)?.toLocaleString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + daySuffix: "2-digit", + }) + : "n/a"} Industry Beverages - Non-Alcoholic{rawData?.industry ?? "n/a"} @@ -153,23 +158,28 @@ class="px-1 py-1.5 font-semibold lg:py-2" data-svelte-h="svelte-5e1uzt">Sector - + item?.title === rawData?.sector, + )?.link} class="sm:hover:text-blue-400 text-white underline underline-offset-4" - href="/stocks/sector/consumer-staples/" - >Consumer Staples{rawData?.sector ? rawData?.sector : "n/a"} EmployeesEmployees 79,100{rawData?.fullTimeEmployees + ? new Intl.NumberFormat("en")?.format( + rawData?.fullTimeEmployees, + ) + : "n/a"} @@ -179,7 +189,7 @@ data-svelte-h="svelte-1qhfmvo">CEO James Robert Quincey{rawData?.ceo || "n/a"} @@ -202,25 +212,24 @@ Address:
- One Coca-Cola Plaza
Atlanta, Georgia 30313
United States + {rawData?.address + ? rawData?.address + : "No Address available"}
{rawData?.city + ? rawData?.city + : "No city data available"}, {rawData?.state ?? ""}
{rawData?.country?.replace("US", "United States") ?? + ""}
- Phone 404 676 2121 + Website - coca-colacompany.com + {rawData?.website ?? "n/a"}Ticker Symbol KO + {rawData?.symbol ?? "n/a"} Exchange NYSE + {rawData?.exchange ?? "n/a"} Fiscal Year January - December{rawData?.fiscalYearRange ?? "n/a"} Reporting Currency USD + {rawData?.currency ?? "n/a"} CIK Code - 0000021344{rawData?.cik ?? "n/a"} CUSIP Number - 191216100{rawData?.cusip ?? "n/a"} ISIN Number - US1912161007{rawData?.isin ?? "n/a"} Employer ID - 58-0628465{rawData?.taxIdentificationNumber ?? "n/a"} SIC Code 2080 + {rawData?.sicCode ?? "n/a"}
-
-

+
+

Key Executives

- - - - - - - - - - - - - - - - - - - - - - - - -
NamePosition
James Robert B. QuinceyChairman and Chief Executive Officer
John MurphyPresident and Chief Financial Officer
Manuel Arroyo PrietoExecutive Vice President and Global chief Marketing Officer
Henrique BraunExecutive Vice President and President of International - Development
Jennifer Kay MannExecutive Vice President and President of North America - Operating Unit
Erin MaySenior Vice President, Chief Accounting Officer and - Controller
Stacy Lynn ApterSenior Vice President, Treasurer and Head of Corporate - Finance
Nancy W. QuanExecutive Vice President and Global Chief Technical and - Innovation Officer
Neeraj TolmareSenior Vice President and Chief Information Officer
Robin HalpernVice President and Head of Investor Relations
- -

+ {#if rawData?.executives?.length > 0} + + + + + {#each rawData?.executives as item} + + + + {/each} + +
NamePosition
{item?.name}{item?.position}
+ {:else} + No executives data available. + {/if} +

Latest SEC Filings

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateTypeTitle
Dec 11, 20248-KCurrent Report
Nov 27, 2024144Filing
Nov 7, 2024144Filing
Oct 24, 202410-QQuarterly Report
Oct 23, 20248-KCurrent Report
Oct 17, 20248-KCurrent Report
Aug 26, 2024144Filing
Aug 21, 20248-KCurrent Report
Aug 21, 2024144Filing
Aug 21, 2024144Filing
+ {#if rawData?.filings?.length > 0} + + + + + + {#each rawData?.filings as item} + + + + + {/each} + +
DateTypeTitle
{item?.date}{item?.type}{item?.title?.length > 50 + ? item?.title?.slice(0, 50) + "..." + : item?.title}
+ {:else} + No SEC filings available. + {/if}