From 481a87367c3c33420aaa3d51334717c6ae47c477 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 24 Aug 2021 12:17:35 +1000 Subject: [PATCH] fix incorrect calendar day labels https://forums.ankiweb.net/t/day-of-the-week-legend-on-heatmap/9450/7 --- ts/lib/i18n_helpers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/lib/i18n_helpers.ts b/ts/lib/i18n_helpers.ts index 9049c906b..6dbf7c53e 100644 --- a/ts/lib/i18n_helpers.ts +++ b/ts/lib/i18n_helpers.ts @@ -61,7 +61,10 @@ export class I18n { weekdayLabel(n: number): string { const firstLang = this.bundles[0].locales[0]; - return new Date(86_400_000 * (3 + n)).toLocaleDateString(firstLang, { + const now = new Date(); + const daysFromToday = -now.getDay() + n; + const desiredDay = new Date(now.getTime() + daysFromToday * 86_400_000); + return desiredDay.toLocaleDateString(firstLang, { weekday: "narrow", }); }