fix: calculating weeks in a year

This commit is contained in:
Polianin Nikita 2024-12-23 05:15:19 +03:00
parent eda6ca4b1a
commit 3aefee124a

View File

@ -141,7 +141,16 @@ export class ScheduleComponent {
} }
get currentWeek(): number { get currentWeek(): number {
let result = (weekInYear(this.startWeek) - weekInYear(this.startTerm)) + 1; const startTermWeek = weekInYear(this.startTerm);
let startWeekNumber;
const startWeek = addDays(this.startWeek, 6);
if (startWeek.getFullYear() > this.startTerm.getFullYear())
startWeekNumber = weekInYear(new Date(this.startTerm.getFullYear(), 11, 29)) + weekInYear(startWeek);
else
startWeekNumber = weekInYear(startWeek);
let result = startWeekNumber - startTermWeek + 1;
if (result <= 0) if (result <= 0)
result = 1; result = 1;