add missing files
This commit is contained in:
@@ -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)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user