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

CustomParseFormat doesn't parse ordinals correctly when AdvancedFormat is enabled #522

Closed
injms opened this issue Mar 7, 2019 · 5 comments
Labels
enhancement New feature or request released

Comments

@injms
Copy link

injms commented Mar 7, 2019

Describe the bug
When using AdvancedFormat plugin that allows ordinals, the CustomParseFormat plugin doesn't parse dates that have ordinals. So:

dayjs('7th March 2019', 'Do MMMM YYYY')

returns

{ [Number: NaN]
  '$L': 'en',
  '$u': undefined,
  '$d': Invalid Date,
  '$y': NaN,
  '$M': NaN,
  '$D': NaN,
  '$W': NaN,
  '$H': NaN,
  '$m': NaN,
  '$s': NaN,
  '$ms': NaN }

Expected behavior
When both AdvancedFormat and CustomParseFormat plugins are enabled

dayjs('7th March 2019', 'Do MMMM YYYY')

should return a dayjs object, either with or without the ordinal defined in it:

{ [Number: 1551916800000]
  '$L': 'en',
  '$u': undefined,
  '$d': '2019-03-07T00:00:00.000Z',
  '$y': 2019,
  '$M': 2,
  '$D': 7,
  '$o': 'th', // maybe?
  '$W': 4,
  '$H': 0,
  '$m': 0,
  '$s': 0,
  '$ms': 0 }

Information

  • Day.js version 1.8.9
  • OS: Windows Subsystem Linux using Node v9.11.2
@iamkun
Copy link
Owner

iamkun commented Mar 7, 2019

It's not a bug related to AdvancedFormat, just because CustomParseFormat does not have the ability to parse token like Do at this version.

@injms
Copy link
Author

injms commented Mar 7, 2019

I was just thinking that because AdvancedFormat can output Do, should CustomParseFormat be able to parse Do?

@iamkun
Copy link
Owner

iamkun commented Mar 7, 2019

should CustomParseFormat be able to parse Do?

This will be a feature request. I think it's good to have.

@iamkun iamkun added the enhancement New feature or request label Mar 7, 2019
@injms
Copy link
Author

injms commented Mar 8, 2019

Thank you 😄

@iamkun iamkun closed this as completed in bf27fda Mar 10, 2019
iamkun pushed a commit that referenced this issue Mar 10, 2019
## [1.8.10](v1.8.9...v1.8.10) (2019-03-10)

### Bug Fixes

* **locale:** Add nepali (ne) locale ([#524](#524)) ([bdbec01](bdbec01))
* Add WeekYear plugin ([a892608](a892608))
* API .locale() with no argument should return current locale name string ([8d63d88](8d63d88))
* CustomParseFormat correct parse HH:mm:ss with only one digit like 0:12:10 ([600d547](600d547))
* CustomParseFormat plugin parse Do format string ([bf27fda](bf27fda)), closes [#522](#522)
* Expand setters like .year(2000) .hour(12) ([ac532a0](ac532a0))
* Move toObject, toArray API to separate plugin from core ([40a3431](40a3431))
@iamkun
Copy link
Owner

iamkun commented Mar 10, 2019

🎉 This issue has been resolved in version 1.8.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.10](iamkun/dayjs@v1.8.9...v1.8.10) (2019-03-10)

### Bug Fixes

* **locale:** Add nepali (ne) locale ([#524](iamkun/dayjs#524)) ([bdbec01](iamkun/dayjs@bdbec01))
* Add WeekYear plugin ([a892608](iamkun/dayjs@a892608))
* API .locale() with no argument should return current locale name string ([8d63d88](iamkun/dayjs@8d63d88))
* CustomParseFormat correct parse HH:mm:ss with only one digit like 0:12:10 ([600d547](iamkun/dayjs@600d547))
* CustomParseFormat plugin parse Do format string ([bf27fda](iamkun/dayjs@bf27fda)), closes [#522](iamkun/dayjs#522)
* Expand setters like .year(2000) .hour(12) ([ac532a0](iamkun/dayjs@ac532a0))
* Move toObject, toArray API to separate plugin from core ([40a3431](iamkun/dayjs@40a3431))
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.10](iamkun/dayjs@v1.8.9...v1.8.10) (2019-03-10)

### Bug Fixes

* **locale:** Add nepali (ne) locale ([#524](iamkun/dayjs#524)) ([bdbec01](iamkun/dayjs@bdbec01))
* Add WeekYear plugin ([a892608](iamkun/dayjs@a892608))
* API .locale() with no argument should return current locale name string ([8d63d88](iamkun/dayjs@8d63d88))
* CustomParseFormat correct parse HH:mm:ss with only one digit like 0:12:10 ([600d547](iamkun/dayjs@600d547))
* CustomParseFormat plugin parse Do format string ([bf27fda](iamkun/dayjs@bf27fda)), closes [#522](iamkun/dayjs#522)
* Expand setters like .year(2000) .hour(12) ([ac532a0](iamkun/dayjs@ac532a0))
* Move toObject, toArray API to separate plugin from core ([40a3431](iamkun/dayjs@40a3431))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

2 participants