fix: show snapshot time in browser time zone (#101)
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 13s
Frontend verify / verify (push) Failing after 6m33s

This commit was merged in pull request #102.
This commit is contained in:
2026-10-24 11:04:50 +03:00
parent 7e6fd95cfa
commit b009101b7b
6 changed files with 27 additions and 9 deletions
+10 -3
View File
@@ -12,9 +12,16 @@ describe("shared display helpers", () => {
expect(formatDate("2027-09-10")).toBe("10.09.2027");
expect(formatDate("2024-02-29")).toBe("29.02.2024");
expect(formatDate("2027-09-10T00:30:00+03:00")).toBe("09.09.2027");
expect(formatSnapshotTime("2027-09-10T00:30:00+03:00")).toBe(
"09.09.2027, 21:30",
);
});
it("formats snapshot time in the browser time zone", () => {
const instant = "2027-09-10T00:30:00+03:00";
const expected = new Intl.DateTimeFormat("ru-RU", {
dateStyle: "short",
timeStyle: "short",
}).format(new Date(instant));
expect(formatSnapshotTime(instant)).toBe(expected);
});
it("formats decimal strings without financial arithmetic", () => {
expect(formatMoney({ currency: "RUB", value: "-1234567.89" })).toBe(
+1 -1
View File
@@ -61,10 +61,10 @@ function formatMoney(
return `${formatDecimal(decimal)} ${currency}`;
}
// Без timeZone Intl берёт часовой пояс браузера пользователя.
const snapshotFormatter = new Intl.DateTimeFormat("ru-RU", {
dateStyle: "short",
timeStyle: "short",
timeZone: "UTC",
});
function formatSnapshotTime(value: string): string {