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

Parse year + week of year #2113

Open Vinze opened 2 years ago

Vinze commented 2 years ago

I'm trying to parse the week of year in the following format: 2022W44. I have included the customParseFormat, advancedFormat, isoWeek and weekOfYear plugins. See the following examples:

dayjs('2022W44', 'YYYY[W]WW'); // Expected: 2022-11-31, got: 2022-01-01
dayjs('2022W07', 'YYYY[W]WW'); // Expected: 2022-02-14, got: 2022-01-01

Did I forgot to include a plugin? Is the parse format invalid? Or did I just found a bug?

dayjs version 1.11.6

felix0220170 commented 2 years ago

symbol 'W' is only used for formatting, can't be used for parsing.

dayjs().format('YYYY[W]WW'); //2022W44

Vinze commented 2 years ago

So parsing of weeknumbers is not possible with dayjs at this moment?