mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
feat(settings): a time-format preference and one home for insight pills
The clock format followed the UI language with no way out — an English interface forced AM/PM everywhere. A new profile preference (automatic, 24-hour, 12-hour) feeds every formatter through the shared locale context, persists on the user row and rides the profile endpoints. The insight pill list in settings gains the same eye toggle the overview tiles have, so ordering and visibility live in one place; the page-side 'manage detail pages' block folds into a link there. Includes the locale bundles for both features and the regenerated API contract.
This commit is contained in:
1 parent
3cf48fa0f1
commit
aabc7915cb
28 files changed
+1137
-462
No files matched your search
@@ -68,20 +68,63 @@ describe("makeFormatters", () => {
|
||||
expect(enFmt.date(sample)).toContain("2026");
|
||||
});
|
||||
|
||||
it("formats 24h time in Europe/Berlin regardless of locale", () => {
|
||||
// v1.15.20 — the hour cycle follows the locale convention by default
|
||||
// (AUTO). Pre-v1.15.20 both locales were pinned to 24h via `hour12:
|
||||
// false`; the explicit preference replaced the pin.
|
||||
it("formats time per the locale convention under AUTO", () => {
|
||||
expect(deFmt.time(sample)).toBe("16:30");
|
||||
expect(enFmt.time(sample)).toBe("16:30");
|
||||
expect(enFmt.time(sample)).toBe("04:30 PM");
|
||||
});
|
||||
|
||||
describe("hour-cycle preference (v1.15.20)", () => {
|
||||
it("AUTO follows the locale default for time + dateTime", () => {
|
||||
const de = makeFormatters("de", undefined, "AUTO");
|
||||
const en = makeFormatters("en", undefined, "AUTO");
|
||||
expect(de.time(sample)).toBe("16:30");
|
||||
expect(en.time(sample)).toBe("04:30 PM");
|
||||
expect(de.dateTime(sample)).toBe("18.04.2026, 16:30");
|
||||
expect(en.dateTime(sample)).toBe("04/18/2026, 04:30 PM");
|
||||
});
|
||||
|
||||
it("H12 forces AM/PM regardless of locale", () => {
|
||||
const de = makeFormatters("de", undefined, "H12");
|
||||
const en = makeFormatters("en", undefined, "H12");
|
||||
expect(de.time(sample)).toContain("PM");
|
||||
expect(en.time(sample)).toBe("04:30 PM");
|
||||
expect(de.dateTime(sample)).toContain("PM");
|
||||
});
|
||||
|
||||
it("H24 forces the 24-hour clock regardless of locale", () => {
|
||||
const de = makeFormatters("de", undefined, "H24");
|
||||
const en = makeFormatters("en", undefined, "H24");
|
||||
expect(de.time(sample)).toBe("16:30");
|
||||
expect(en.time(sample)).toBe("16:30");
|
||||
expect(en.dateTime(sample)).toBe("04/18/2026, 16:30");
|
||||
});
|
||||
|
||||
it("H24 renders midnight as 00, never 24 (h23 cycle)", () => {
|
||||
const midnight = new Date("2026-04-18T22:30:00Z"); // 00:30 Berlin CEST
|
||||
const en = makeFormatters("en", undefined, "H24");
|
||||
expect(en.time(midnight)).toBe("00:30");
|
||||
});
|
||||
|
||||
it("does not affect date-only formatters", () => {
|
||||
const auto = makeFormatters("en", undefined, "AUTO");
|
||||
const h24 = makeFormatters("en", undefined, "H24");
|
||||
expect(auto.date(sample)).toBe(h24.date(sample));
|
||||
expect(auto.dateShort(sample)).toBe(h24.dateShort(sample));
|
||||
});
|
||||
});
|
||||
|
||||
// v1.4.25 W7 — formatters accept a per-user timezone override.
|
||||
it("renders time in the user's tz when userTz is passed", () => {
|
||||
const tokyo = makeFormatters("en", "Asia/Tokyo");
|
||||
const tokyo = makeFormatters("en", "Asia/Tokyo", "H24");
|
||||
// 14:30 UTC = 23:30 Tokyo
|
||||
expect(tokyo.time(sample)).toBe("23:30");
|
||||
});
|
||||
|
||||
it("renders time in Europe/Berlin when userTz is empty", () => {
|
||||
const fallback = makeFormatters("en", "");
|
||||
const fallback = makeFormatters("en", "", "H24");
|
||||
expect(fallback.time(sample)).toBe("16:30");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user