Fix Invalid Date for datetime strings from API
The API returns dates as "2024-12-11T00:00:00" (datetime, no timezone), not bare "2024-12-11". Appending T12:00:00 directly produced an invalid string. Use .slice(0, 10) to extract the date part first before parsing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ interface SessionDetail {
|
||||
}
|
||||
|
||||
function formatDate(iso: string): string {
|
||||
const d = new Date(iso + "T12:00:00");
|
||||
const d = new Date(iso.slice(0, 10) + "T12:00:00");
|
||||
return d.toLocaleDateString(undefined, { weekday: "long", year: "numeric", month: "long", day: "numeric" });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user