From 85174e1df0f29aaba61325f731c4f6f7afc429df Mon Sep 17 00:00:00 2001 From: Jonathan <523261+jcfrei@users.noreply.github.com> Date: Wed, 29 Jul 2026 15:47:38 +0200 Subject: [PATCH] fix(ui): date locale configurable, default browser (was hardcoded en-US) formatDate forced "en-US" (US month/day order + English month), so every deployment showed US-style dates regardless of the viewer. Now numeric and day/month per a configurable locale, defaulting to the viewer's browser locale; setDateLocale(locale) pins it (e.g. "de-CH" -> DD.MM.YYYY). Both exported. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 13 +++++++++++++ frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- frontend/src/index.ts | 4 ++++ frontend/src/lib/utils.ts | 19 +++++++++++++++---- pyproject.toml | 2 +- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d86821..aeed6c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,19 @@ semver-governed public surface — a breaking change to a seam is a major bump. ## [Unreleased] +## [0.6.9] - 2026-07-29 + +### Fixed +- **Dates no longer force US format.** `formatDate` hardcoded the `"en-US"` + locale (and an English short month), so every deployment showed US-style + dates regardless of the viewer. It now formats numeric, day/month per the + configured locale, defaulting to the **viewer's browser locale**. A + deployment can pin it with the new **`setDateLocale(locale)`** (e.g. + `setDateLocale("de-CH")` for `DD.MM.YYYY` everywhere). `setDateLocale` and + `formatDate` are exported from the package. + Note: native `` pickers still render in the browser/OS + locale — that's the platform, not this formatter. + ## [0.6.8] - 2026-07-29 ### Added diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 665c0c2..7bec71d 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lambda-development/erp-core", - "version": "0.6.8", + "version": "0.6.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@lambda-development/erp-core", - "version": "0.6.8", + "version": "0.6.9", "license": "Apache-2.0", "dependencies": { "@fontsource/inter": "^5.2.8" diff --git a/frontend/package.json b/frontend/package.json index e9927e1..ba43523 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@lambda-development/erp-core", - "version": "0.6.8", + "version": "0.6.9", "description": "Frontend core of Lambda ERP — app shell, document/master pages, chat UI, reports, and extension registries.", "license": "Apache-2.0", "repository": { diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 59fabce..2f1831a 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -55,6 +55,10 @@ export type { ListContext } from "./lib/doc-list-context"; export { configureBranding, getBranding } from "./lib/branding"; export type { Branding } from "./lib/branding"; +// Date display locale (default: viewer's browser locale). Pin per deployment, +// e.g. setDateLocale("de-CH"). +export { setDateLocale, formatDate } from "./lib/utils"; + // API client export { api, request, ApiError, configureApiBase } from "./api/client"; diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index c6c8f1c..1d3f3d9 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -20,13 +20,24 @@ export function formatNumber(value: number | null | undefined, decimals = 2) { }).format(value ?? 0); } -/** Format a date string for display. */ +// Display locale for dates. Default: the viewer's browser locale — the old +// hardcoded "en-US" forced US month/day order (and English month names) on +// every deployment. A deployment can pin it, e.g. setDateLocale("de-CH") for +// DD.MM.YYYY everywhere, regardless of the viewer's browser. +let dateLocale: string | undefined; + +/** Pin the locale used by formatDate (undefined = the viewer's browser locale). */ +export function setDateLocale(locale: string | undefined) { + dateLocale = locale; +} + +/** Format a date string for display (numeric, day-first per the locale). */ export function formatDate(value: string | null | undefined) { if (!value) return ""; - return new Date(value).toLocaleDateString("en-US", { + return new Date(value).toLocaleDateString(dateLocale, { year: "numeric", - month: "short", - day: "numeric", + month: "2-digit", + day: "2-digit", }); } diff --git a/pyproject.toml b/pyproject.toml index 62a6bd5..ab8e43d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lambda-erp" -version = "0.6.8" +version = "0.6.9" description = "Core ERP logic - accounting, sales, purchasing, inventory" readme = "README.md" license = "Apache-2.0"