Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure locale & timezone controlled in test #360

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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