add missing files

This commit is contained in:
JCEEE
2026-08-04 17:39:28 +01:00
parent 97bd679954
commit 6e817be13f
6 changed files with 25 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
// Format a YYYY-MM-DD (or ISO) string as DDMMYY for user-facing dates.
export function formatDDMMYY(dateStr: string | undefined): string {
if (!dateStr) return '';
const d = new Date(dateStr.slice(0, 10) + 'T00:00:00');
const day = String(d.getDate()).padStart(2, '0');
const mon = String(d.getMonth() + 1).padStart(2, '0');
const yr = String(d.getFullYear()).slice(2);
return `${day}${mon}${yr}`;
}
// Human-friendly date for due dates etc: "5 Aug" (adds year when not the
// current one, e.g. "5 Aug 26"). Better than the compact DDMMYY code.
export function formatShortDate(dateStr: string | undefined): string {
if (!dateStr) return '';
const d = new Date(dateStr.slice(0, 10) + 'T00:00:00');
if (Number.isNaN(d.getTime())) return '';
const mon = d.toLocaleDateString('en-GB', { month: 'short' });
const sameYear = d.getFullYear() === new Date().getFullYear();
return `${d.getDate()} ${mon}${sameYear ? '' : ' ' + String(d.getFullYear()).slice(2)}`;
}