Skip to content

Conversation

@lizhihangdev
Copy link

Background
After using dayjs to replace moment, I found that dayjs does not support moment's ability to parse ISO 8601 strings.

For example
dayjs('2024-W01', 'GGGG-[W]WW')

Solution
dayjs(newDate).add(7, 'day').isoWeek(isoWeek).isoWeekday(1)

  • Get the correct ISO year,dayjs(newDate).add(7, 'day')
  • Generate dayjs according to ISO week,dayjs(newDate).add(7, 'day').isoWeek(isoWeek)
  • Take the value of Monday as the final result,dayjs(newDate).add(7, 'day').isoWeek(isoWeek).isoWeekday(1)

@lizhihangdev
Copy link
Author

dependent IsoWeek plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant