fix incorrect calendar day labels

https://forums.ankiweb.net/t/day-of-the-week-legend-on-heatmap/9450/7
This commit is contained in:
Damien Elmes 2021-08-24 12:17:35 +10:00
parent d8a0df2a62
commit ab8e53f66e

View file

@ -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",
});
}