question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CustomParseFormat doesn't parse ordinals correctly when AdvancedFormat is enabled

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iamkuncommented, Mar 10, 2019

🎉 This issue has been resolved in version 1.8.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

0reactions
injmscommented, Mar 8, 2019

Thank you 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found