Skip to content

Commit

Permalink
fix: ensure locale & timezone controlled in test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrynes7 committed Nov 26, 2024
1 parent d6b25f7 commit 2418bf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin/src/data/dueDateFormatter.ts
Original file line number Diff line number Diff line change
@@ -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<string, Intl.DateTimeFormatOptions> = {
time: {
Expand All @@ -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];
};

Expand Down
6 changes: 6 additions & 0 deletions plugin/src/data/transformations/grouping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>): Task {
return {
id,
Expand Down

0 comments on commit 2418bf4

Please sign in to comment.