Closed AlbinSoft closed 6 months ago
Luxon uses the ISO week date for calculating weekYear
and weekNumber
. This means that January 1st in the Gregorian calendar is not necessarily week 1 of the same week year. In your example, the week with 2024-12-30 and 2024-12-31 (a Monday and a Tuesday, i.e. first and second day of the week in the ISO week system) has the majority of its days in January of 2025. That means this week is by definition the first week of the 2025 week year. This means that 2024-12-30 and 2024-12-31 are also part of the first week of the week year 2025.
You can use localeWeekYear
and localeWeekNumber
to get a week year calculation which is based on the locale, which might align better with your expectation. Do note however that many locales (such as de-DE) use the same rules as the ISO week date.
Describe the bug I my opinion there is some bug calculating which week of the year is.
To Reproduce https://codepen.io/albinsoft/pen/RwdPZxQ?editors=0011
Actual vs Expected behavior For the date 2024-12-30 It returns the number 1 instead of 52. And should return the number 1 since 2025-01-01, althouth it is the same week, it is not when you are counting how many have happend along the year.