fix: preserve OHLCV stale detection

This commit is contained in:
2026-08-04 07:39:40 +02:00
parent d431ee283d
commit d1caac86b5
4 changed files with 61 additions and 7 deletions
+3 -2
View File
@@ -77,7 +77,8 @@ function marketDate(date = new Date()): string {
}
function formatSessionDate(isoDate: string): string {
if (isoDate === marketDate()) return 'Today';
const currentMarketDate = marketDate();
if (isoDate === currentMarketDate) return 'Today';
// Parse date-only market sessions explicitly. Parsing YYYY-MM-DD directly as
// a Date means midnight UTC and makes today's bar look many hours old.
@@ -86,7 +87,7 @@ function formatSessionDate(isoDate: string): string {
return new Intl.DateTimeFormat(undefined, {
month: 'short',
day: 'numeric',
year: year === new Date().getFullYear() ? undefined : 'numeric',
year: year === Number(currentMarketDate.slice(0, 4)) ? undefined : 'numeric',
timeZone: 'UTC',
}).format(new Date(Date.UTC(year, month - 1, day)));
}