mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(settings): let every date follow a date format of the user's choice
Every date in TREK was written in the interface language's format, and English is en-US, so an English interface always showed and read mm/dd/yyyy with no way to change it. A few native date inputs followed the browser instead, so one screen could mix two formats. date_format is now a user setting with an admin default, next to the time format: automatic (the language's format, as before), YYYY-MM-DD, YYYY/MM/DD, DD.MM.YYYY, DD/MM/YYYY or MM/DD/YYYY. The date picker shows, pre-fills, hints and reads typed dates in it, and every date written in numbers across the app (lists, cards, admin panels, CSV and PDF exports) goes through one formatter. Dates written with a month name keep the language's wording. The remaining native date inputs are the shared picker now. The display settings MCP tool reads and writes the key. Closes #2971
This commit is contained in:
@@ -35,6 +35,20 @@ export const DEFAULT_WEEK_START: WeekStart = 'monday';
|
||||
/** Date#getDay() of each value, the number a calendar grid computes with. */
|
||||
export const WEEK_START_DAY: Record<WeekStart, number> = { monday: 1, sunday: 0, saturday: 6 };
|
||||
|
||||
/**
|
||||
* How a date is written wherever TREK writes one in numbers: every date field,
|
||||
* shown and typed, and every numeric date in lists, cards and exports (#2971).
|
||||
* 'auto' follows the interface language, which is what every date did before
|
||||
* the setting existed (English is en-US, so mm/dd/yyyy). The others name their
|
||||
* own order and separator. Dates written with a month name ("3 Nov") keep the
|
||||
* language's wording either way.
|
||||
*/
|
||||
export const DATE_FORMAT_VALUES = ['auto', 'YYYY-MM-DD', 'YYYY/MM/DD', 'DD.MM.YYYY', 'DD/MM/YYYY', 'MM/DD/YYYY'] as const;
|
||||
export type DateFormat = (typeof DATE_FORMAT_VALUES)[number];
|
||||
export const dateFormatSchema = z.enum(DATE_FORMAT_VALUES);
|
||||
/** What a user who never picked one gets. */
|
||||
export const DEFAULT_DATE_FORMAT: DateFormat = 'auto';
|
||||
|
||||
// ── Responses ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** GET /api/settings: the user's preferences by key, each value as getUserSettings parsed it (secrets masked). */
|
||||
|
||||
Reference in New Issue
Block a user