iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
46.97k stars 2.3k forks source link

isoWeek overwrites year? #1550

Open Helfull opened 3 years ago

Helfull commented 3 years ago
Describe the bug I am trying to get the start and end of a given iso week e.g.: Week start end
Week 22 May 31, 2021 June 6, 2021
Week 23 June 7, 2021 June 13, 2021
Week 24 June 14, 2021 June 20, 2021

Taken from https://www.epochconverter.com/weeks/2021

If i set my date like this

dayjs('21', 'YY').isoWeek(23)

i get back for startOf('isoWeek') the 01.06.2020 which does overwrite the year i set.

Expected behavior Here is an example with assertions of what i expect https://github.com/Helfull/dayjs-bug

Information

okms commented 2 years ago

I can confirm this behavior, which breaks parsing of weeks in 2021, 2027, 2032 etc

rush86999 commented 1 year ago

I can also confirm this behavior.

Please be careful with isoWeek.

I need to review all my code because of this