From 7c40f028c88d7fd78ac8ab75c172d808783fc641 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 7 Nov 2025 10:08:12 -0600 Subject: [PATCH] fix(historical inv): corrected the way the date can come over to allow for yyyy-mm-dd or with / the date was coming over in utc format somnetimes and others times local. close #1 correction to the date formats --- .../eom/controller/getHistoricalInvByDate.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lstV2/server/services/eom/controller/getHistoricalInvByDate.ts b/lstV2/server/services/eom/controller/getHistoricalInvByDate.ts index 4ee0cb9..b78b37d 100644 --- a/lstV2/server/services/eom/controller/getHistoricalInvByDate.ts +++ b/lstV2/server/services/eom/controller/getHistoricalInvByDate.ts @@ -80,8 +80,27 @@ export const historicalInvByDate = async ( date: string, includePlantToken: boolean = false, ) => { - const histDate = new Date(date); + console.log(date); + // date format should always be yyyy-MM-dd or yyyy-MM-dd + let splitDate: string[]; + if (date.includes("/")) { + splitDate = date.split("/"); + } else if (date.includes("-")) { + splitDate = date.split("-"); + } else { + return { + success: false, + message: "An invalid date was passed over", + data: [], + }; + } + const year = parseInt(splitDate[0], 10); + const month = parseInt(splitDate[1], 10) - 1; // zero-based months + const day = parseInt(splitDate[2], 10); + const histDate = new Date(year, month, day); + console.log(histDate); + console.log(format(histDate, "yyyy-MM-dd")); const { data, error } = (await tryCatch( db .select()