dayjs
dayjs copied to clipboard
Incorrect ISO Week Calculation
Describe the bug
When using startOf and endOf functions for the ISO week in Day.js version 1.11.10, the resulting dates are incorrect. Specifically, for week 52 of the year 2023, the expected output should be from December 25th to December 31st, but the actual output is from December 26th to January 1st.
Expected behavior
The startOf and endOf functions for the ISO week should correctly return the start and end dates of the specified week. For week 52 of 2023, it should output December 25th (Monday) as the start date and December 31st (Sunday) as the end date.
Information
Day.js Version: 1.11.10 OS: MacOS Browser: Version 1.21.2 (44530) Time zone: GMT-05:30 IST
Steps to Reproduce
Use Day.js version 1.11.10. Call the startOf('isoWeek') and endOf('isoWeek') functions for week 52 of the year 2023. Actual Results The output is December 26th to January 1st instead of December 25th to December 31st.
Code
Playground - https://stackblitz.com/edit/dayjs-playground-s476mq?file=index.js
Screenshot
It appears that this bug is no longer present on various dates; specifically, it only manifested on January 1, 2024.
Link to the issue: https://stackblitz.com/edit/dayjs-playground-kea4tn?file=index.js
Actually there is an error and it's visible here: https://stackblitz.com/edit/dayjs-playground-brkata?file=index.js
there is 6 days overlap between those 2 weeks and 1st week of 2027 starts at Tuesday, while in iso standards it should always start at monday. So correct Start date for 1st week of 2027 should be Jan 04.
@matigda are you from future? 😮