CustomParseFormat doesn't parse ordinals correctly when AdvancedFormat is enabled
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ParseExact not parsing string with day, date with ordinal ...
I have reviewed the answer to Parse very long date format to DateTime in C# and it goes a little way to fixing...
Read more >dayjs-ext | Yarn - Package Manager
New plugin "customParseFormat" to parse input strings using custom formats. New plugin "localizableFormat" to format dates according to the chosen locale.
Read more >dayjs
customParseFormat plugin to parse comma as a separator character (#1913) (41b1405) ... update Slovenian [sl] locale to set correct ordinal (#1386) (cb4f746) ...
Read more >String + Format
dayjs.extend(customParseFormat) dayjs("12-25-1995", "MM-DD-YYYY"). Pass the locale key as the third parameter to parse locale-aware date time string.
Read more >Add Latin locale #961
<anonymous> (test/plugin/timezone.test.js:198:21) PASS test/parse.test.js FAIL ... relativeTime ; it does not talk about locale.formats .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 This issue has been resolved in version 1.8.10 🎉
The release is available on:
Your semantic-release bot 📦🚀
Thank you 😄