Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dayjs format 'YYYY-ww' error #2012

Open
a145789 opened this issue Aug 5, 2022 · 1 comment
Open

dayjs format 'YYYY-ww' error #2012

a145789 opened this issue Aug 5, 2022 · 1 comment

Comments

@a145789
Copy link

a145789 commented Aug 5, 2022

Describe the bug

<script src="https://unpkg.com/dayjs@1.11.4/dayjs.min.js"></script>
<script src="https://unpkg.com/dayjs@1.11.4/plugin/weekOfYear.js"></script>
<script src="https://unpkg.com/dayjs@1.11.4/plugin/weekYear.js"></script>
<script src="https://unpkg.com/dayjs@1.11.4/plugin/advancedFormat.js"></script>
<script src="https://unpkg.com/dayjs@1.11.4/plugin/customParseFormat.js"></script>

<script>
  dayjs.extend(window.dayjs_plugin_advancedFormat)
  dayjs.extend(window.dayjs_plugin_customParseFormat)
  dayjs.extend(window.dayjs_plugin_weekOfYear)
  dayjs.extend(window.dayjs_plugin_weekYear)
  var date = dayjs("2022-31", "YYYY-ww").toDate()
  console.log(date); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
  console.log(dayjs(date).format('YYYY-ww')); // 2022-01

</script>

Expected behavior

  console.log(dayjs(date).format('YYYY-ww')); // 2022-31

Information

  • Day.js Version [e.g. v1.11.4]
  • Browser [e.g. chrome 103.0.5060.134]
  • Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]
@Bykiev
Copy link

Bykiev commented Aug 5, 2022

Hi, according to the docs ww is not a valid parsing token, that's why it's not working.

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

No branches or pull requests

2 participants