fix #37: monthly expense charts

:
This commit is contained in:
Vasily Zubarev
2025-08-02 21:28:47 +02:00
parent a5a2e3053b
commit 280adabc71
6 changed files with 565 additions and 2 deletions

View File

@@ -116,3 +116,21 @@ export function generateUUID(): string {
return v.toString(16)
})
}
export function formatPeriodLabel(period: string, date: Date): string {
if (period.includes("-") && period.split("-").length === 3) {
// Daily format: show day/month/year
return date.toLocaleDateString("en-US", {
weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
})
} else {
// Monthly format: show month/year
return date.toLocaleDateString("en-US", {
month: "long",
year: "numeric",
})
}
}