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

Issue formatting 02/20 #711

Closed
mason-terry opened this issue Oct 30, 2019 · 5 comments
Closed

Issue formatting 02/20 #711

mason-terry opened this issue Oct 30, 2019 · 5 comments

Comments

@mason-terry
Copy link

mason-terry commented Oct 30, 2019

Describe the bug
const month = dayjs.utc(02/20, 'MM/YY').format('MM')
const year = dayjs.utc(02/20, 'MM/YY').format('YYYY')

The above returns:

month = 03
year = 2020

Expected behavior
month = 02
year = 2020

Additional Information
I think this is a leap year issue

Information

  • Day.js Version: v1.8.16
  • OS: MacOS 10.14
  • Browser Chrome 78
  • Time zone: GMT-06:00 DST (Central Daylight Time)
@iamkun
Copy link
Owner

iamkun commented Oct 31, 2019

https://runkit.com/embed/ydhiaf56iwjl

Screen Shot 2019-11-01 at 1 02 14 AM

please provide a valid reproduction link

@marc-fisher-q2e
Copy link

Odd, just cloning that example I see a different result, no changes.

https://runkit.com/svjard/5dbb2da38795ea001414b056

@mason-terry
Copy link
Author

mason-terry commented Oct 31, 2019

I got the same results as ☝️ "03"

@iamkun
Copy link
Owner

iamkun commented Nov 1, 2019

This is because if no 'day' provided, dayjs will use current 'day'. But we might change it to the first day of the month. And 02-31 -> 03-01.

@iamkun
Copy link
Owner

iamkun commented Jan 6, 2020

fixed in #761 and will use the first day of the month while there's no 'day' provided.

@iamkun iamkun closed this as completed Jan 6, 2020
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

3 participants