Skip to content

Commit 146077e

Browse files
committed
Fix for inconsistent date handling for graphs
1 parent ed8e1a8 commit 146077e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/webapp/app/components/primitives/charts/DateRangeContext.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ export function formatChartDateLong(date: Date): string {
3636
}
3737

3838
/**
39-
* Convert a Date to ISO date string (YYYY-MM-DD)
39+
* Convert a Date to ISO date string (YYYY-MM-DD) using local date components
4040
*/
4141
export function toISODateString(date: Date): string {
42-
return date.toISOString().split("T")[0];
42+
const year = date.getFullYear();
43+
const month = String(date.getMonth() + 1).padStart(2, "0");
44+
const day = String(date.getDate()).padStart(2, "0");
45+
return `${year}-${month}-${day}`;
4346
}
4447

4548
/**
46-
* Parse an ISO date string to a Date object
49+
* Parse an ISO date string (YYYY-MM-DD) to a local Date object
4750
*/
4851
export function parseISODateString(isoString: string): Date {
49-
return new Date(isoString + "T00:00:00");
52+
const [year, month, day] = isoString.split("-").map(Number);
53+
return new Date(year, month - 1, day);
5054
}
5155

5256
/**

0 commit comments

Comments
 (0)