refactor(frontend): extract toActionResult helper and formatDate utility
- Admin page: replace 7 identical error-handling blocks with a single toActionResult() helper — DRY without over-abstraction - New date.ts util: formatDate(isoDate) centralises the T12:00:00 timezone guard and Intl.DateTimeFormat locale config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
11
frontend/src/lib/utils/date.ts
Normal file
11
frontend/src/lib/utils/date.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Format an ISO date string (YYYY-MM-DD) for display.
|
||||
* Uses T12:00:00 to avoid UTC timezone off-by-one when converting to local time.
|
||||
*/
|
||||
export function formatDate(isoDate: string): string {
|
||||
return new Intl.DateTimeFormat('de-DE', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric'
|
||||
}).format(new Date(isoDate + 'T12:00:00'));
|
||||
}
|
||||
Reference in New Issue
Block a user