From 2418bf48bdb2e058d36b44949c94d26cd808704c Mon Sep 17 00:00:00 2001 From: Jamie Brynes Date: Tue, 26 Nov 2024 20:53:31 +0000 Subject: [PATCH] fix: ensure locale & timezone controlled in test --- plugin/src/data/dueDateFormatter.ts | 6 +++++- plugin/src/data/transformations/grouping.test.ts | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/src/data/dueDateFormatter.ts b/plugin/src/data/dueDateFormatter.ts index 22f4f8d..13925a2 100644 --- a/plugin/src/data/dueDateFormatter.ts +++ b/plugin/src/data/dueDateFormatter.ts @@ -1,6 +1,7 @@ import type { DueDate } from "@/data/dueDate"; import { t } from "@/i18n"; import { locale } from "@/infra/locale"; +import { timezone } from "@/infra/time"; const formatStyles: Record = { time: { @@ -27,7 +28,10 @@ const getFormatter = (style: string): Intl.DateTimeFormat => { return formatterCache[style]; } - formatterCache[style] = new Intl.DateTimeFormat(locale(), formatStyles[style]); + formatterCache[style] = new Intl.DateTimeFormat(locale(), { + timeZone: timezone(), + ...formatStyles[style], + }); return formatterCache[style]; }; diff --git a/plugin/src/data/transformations/grouping.test.ts b/plugin/src/data/transformations/grouping.test.ts index e87854b..9f20543 100644 --- a/plugin/src/data/transformations/grouping.test.ts +++ b/plugin/src/data/transformations/grouping.test.ts @@ -16,6 +16,12 @@ vi.mock("../../infra/time.ts", () => { }; }); +vi.mock("../../infra/locale.ts", () => { + return { + locale: () => "en-US", + }; +}); + function makeTask(id: string, opts?: Partial): Task { return { id,