diff --git a/src/utils/calculateWeekNum.ts b/src/utils/calculateWeekNum.ts index b7ebbc7..35e5428 100644 --- a/src/utils/calculateWeekNum.ts +++ b/src/utils/calculateWeekNum.ts @@ -2,12 +2,13 @@ export default (date: Date): { weekYear: number, weekNum: number } => { const tempDate = new Date(date) tempDate.setHours(0, 0, 0, 0) - tempDate.setDate(tempDate.getDate() + 3 - (tempDate.getDay() || 7)) + tempDate.setDate(tempDate.getDate() + 4 - (tempDate.getDay() || 7)) - const firstFriday = new Date(tempDate.getFullYear(), 0, 5) // Changed to 5 for Friday - firstFriday.setDate(firstFriday.getDate() + 3 - (firstFriday.getDay() || 7)) + const forthDay = new Date(tempDate.getFullYear(), 0, 4) + console.log(forthDay) + forthDay.setDate(forthDay.getDate() + 4 - (forthDay.getDay() || 7)) - const diffInDays = Math.floor((tempDate.getTime() - firstFriday.getTime()) / (24 * 60 * 60 * 1000)) + const diffInDays = Math.floor((tempDate.getTime() - forthDay.getTime()) / (24 * 60 * 60 * 1000)) const weekNum = Math.ceil((diffInDays + 1) / 7)