Skip to content

Commit 3b9da78

Browse files
committed
Avoid formatting with the iso8601 calendar, because Node 22 does it wrong.
1 parent 1463211 commit 3b9da78

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

webserver/e2e/history.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ test("Save history", async ({
113113

114114
await page.getByRole("button", { name: "🍲" }).click();
115115

116-
const ym = Temporal.Now.plainDateISO().toPlainYearMonth();
116+
const today = Temporal.Now.plainDateISO();
117117
await expect(
118118
page.locator("#cooking-history").getByRole("listitem")
119119
).toHaveText([
120-
ym.toLocaleString("en", {
120+
today.toLocaleString("en", {
121121
month: "short",
122122
year: "numeric",
123-
calendar: ym.calendarId,
124123
}),
125124
"Apr 2023",
126125
]);

webserver/src/components/HistoryList.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import { OneRecipe, type RecipeTitleWithLinkFields } from "./OneRecipe";
1717
import { QueryDrivenTextField } from "./QueryDrivenTextField";
1818

1919
function formatMonth(m: Temporal.PlainYearMonth) {
20-
return m.toLocaleString(undefined, {
21-
calendar: m.calendarId,
20+
// Avoid using the PlainYearMonth's calendar, which is probably iso8601, because Node 22 formats
21+
// it differently from the default Gregorian calendar.
22+
return m.toPlainDate({ day: 1 }).toLocaleString(undefined, {
2223
year: "numeric",
2324
month: "short",
2425
});

webserver/src/pages/r/[username]/[slug].astro

+6-6
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ if (cookingHistoryAddResult?.error) {
248248
<li>
249249
<time
250250
datetime={ym.toString()}
251-
title={`${ym.toLocaleString("en", {
252-
month: "short",
253-
calendar: ym.calendarId,
254-
})} ${andList.format(days.sort(numericAscending).map(String))}`}
251+
title={`${ym
252+
.toPlainDate({ day: 1 })
253+
.toLocaleString("en", {
254+
month: "short",
255+
})} ${andList.format(days.sort(numericAscending).map(String))}`}
255256
>
256-
{ym.toLocaleString("en", {
257+
{ym.toPlainDate({ day: 1 }).toLocaleString("en", {
257258
month: "short",
258259
year: "numeric",
259-
calendar: ym.calendarId,
260260
})}
261261
</time>
262262
</li>

0 commit comments

Comments
 (0)