fix: correct week number calculation logic in calculateWeekNum utility
All checks were successful
Publish to npm / publish (push) Successful in 29s
All checks were successful
Publish to npm / publish (push) Successful in 29s
This commit is contained in:
parent
39ffb6f784
commit
ca571736ab
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user