Skip to content

Commit

Permalink
Revert "Fix getWeekIsoNumber"
Browse files Browse the repository at this point in the history
This reverts commit 733a5dd.
  • Loading branch information
oscarfgq authored and geoperez committed Jul 12, 2024
1 parent 8eb15a4 commit e442a3e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/weekUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ export const getWeekNumber = (date: Date) => {

export const getWeekOfYear = (): number => getWeekNumber(new Date());

export const getWeekIsoNumber = (date: Date) => {
const onejan = new Date(date.getFullYear(), 0, 1);
const daysSinceOneJan = Math.floor((date.getTime() - onejan.getTime()) / 86400000);
const dayOfWeek = (onejan.getDay() + 6) % 7;
return Math.floor((daysSinceOneJan + dayOfWeek) / 7) + 1;
export const getWeekIsoNumber = (date: Date): number => {
const dayOfWeek = date.getDay();
const thursday = new Date(date.getFullYear(), date.getMonth(), date.getDate() + (4 - dayOfWeek));
return Math.ceil(((thursday.getTime() - new Date(thursday.getFullYear(), 0, 1).getTime()) / 86400000 + 1) / 7);
};

export const getWeekIsoOfYear = (): number => getWeekIsoNumber(new Date());

0 comments on commit e442a3e

Please sign in to comment.