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 work when format doesn't fit the Date

See original GitHub issue

Issuehunt badges

dayjs('2019/04/19, 'MMDDYY').isValid() returns true and it parses to Wed Jul 20 2005.

Moment.js does not parse it.

https://jsfiddle.net/3meh8g0k/

You can get the same results using other different formats (e.g dayjs('2019/04/19, ‘MM’ returns Mon May 20 2019)


IssueHunt Summary

iamkun iamkun has been rewarded.

Backers (Total: $100.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
mireflycommented, Jun 4, 2019

@iamkun Thanks, but I feel I might have confused you… I am not proposing to ignore separator tokens, but to require exact matching between input string and format.

 dayjs('2019/04/19, 'YYYYMMDD') ---> invalid
 dayjs('2019/04/19, 'YYYY/MM/DD') ---> 2019/04/19
 dayjs('2019/04/19ab, 'YYYY/MM/DD') ---> invalid, not allowing characters left after parsing
4reactions
huytdcommented, Sep 17, 2019

@iamkun I think what @mirefly proposing is a good approach. Is there any concern you have?

I’d like to chime in and try implement it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Format custom date using dayjs without using ... - Stack Overflow
The reason why you are getting Invalid Date is because the iso8601Format string does not match dayjs's parsing tokens.
Read more >
iamkun/dayjs: customParseFormat doesn't work when format ...
customParseFormat doesn't work when format doesn't fit the Date #605 ... You can get the same results using other different formats (e.g ...
Read more >
CustomParseFormat
CustomParseFormat extends `dayjs()` constructor to support custom formats of input strings.
Read more >
iamkun/dayjs - Gitter
Hi guys, dayjs how to format date to rfc3339 format ? like ... When I try to attach a timezone to it, it...
Read more >
How to Fix Excel Dates That Won't Change Format - Contextures
Note: All of the built-in date formatting options should work correctly, after you have converted the text dates to real dates. real dates...
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