Fixed dates

This commit is contained in:
Simon Pocrnjič
2026-04-14 17:41:05 +02:00
parent 821985469e
commit 7881508a7b
6 changed files with 52 additions and 23 deletions
+8 -4
View File
@@ -33,8 +33,12 @@ export function fmtDateDMY(value) {
if (!value) return "-";
const d = new Date(value);
if (isNaN(d)) return "-";
const dd = String(d.getDate()).padStart(2, "0");
const mm = String(d.getMonth() + 1).padStart(2, "0");
const yyyy = d.getFullYear();
return `${dd}.${mm}.${yyyy}`;
const parts = new Intl.DateTimeFormat("en-GB", {
timeZone: "Europe/Ljubljana",
day: "2-digit",
month: "2-digit",
year: "numeric",
}).formatToParts(d);
const map = Object.fromEntries(parts.map((p) => [p.type, p.value]));
return `${map.day}.${map.month}.${map.year}`;
}