fix some issues - including add ledger page and fix reoccuring completions

This commit is contained in:
JCEEE
2026-08-05 09:03:08 +01:00
parent 6e817be13f
commit d162ea762e
14 changed files with 993 additions and 546 deletions
+20 -6
View File
@@ -1,20 +1,34 @@
// Format a YYYY-MM-DD (or ISO) string as DDMMYY for user-facing dates.
// Two date display views used across the app:
// - Data view: `08-08-26` (dashed DD-MM-YY) — compact, tabular-friendly.
// - Human view: weekday in a badge (`Thursday`) with month/year added per requirement.
// Format a YYYY-MM-DD (or ISO) string as a compact dashed data-view date.
export function formatDDMMYY(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 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}`;
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 {
// Human view — the weekday name ("Thursday"). Render this inside a badge.
export function formatWeekday(dateStr: string | undefined): string {
if (!dateStr) return '';
const d = new Date(dateStr.slice(0, 10) + 'T00:00:00');
if (Number.isNaN(d.getTime())) return '';
return d.toLocaleDateString('en-GB', { weekday: 'long' });
}
// Human view — weekday + short date ("Thursday 7 Aug", adds year when not the
// current one, e.g. "Thursday 7 Aug 26").
export function formatHumanDate(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 weekday = d.toLocaleDateString('en-GB', { weekday: 'long' });
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)}`;
return `${weekday} ${d.getDate()} ${mon}${sameYear ? '' : ' ' + String(d.getFullYear()).slice(2)}`;
}