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

Loading the customParseFormat plugin causes parsing some formats to return invalid dates #1802

Open
RobM-ADP opened this issue Feb 10, 2022 · 1 comment

Comments

@RobM-ADP
Copy link

When parsing dates using the following format:

dddd, MMMM D, YYYY h:mm A

parsing works correctly until you load the customParseFormat plugin at which point parsing of the date no longer works. For example, using the following code formatting the date to the huge format and then parsing it does not work. If you remove this line: dayjs.extend(window.dayjs_plugin_customParseFormat); then it works as expected.

// if you don't load this plugin the parsing works as expected
dayjs.extend(window.dayjs_plugin_customParseFormat);

const hugeFormat = 'dddd, MMMM D, YYYY h:mm A';
// format as huge
const hugeFeb16 = dayjs('2022-02-16').format(hugeFormat);
console.log(hugeFeb16);

// parse huge formatted expecting to be valid
console.log(dayjs(hugeFeb16, hugeFormat, false).isValid());

https://jsfiddle.net/mcgraphix/2qk5t61m/7/

Expected behavior
I would expect that the addition of the plugin would not break parsing of other formats

Information

  • Day.js Version 1.10.1
  • OS: Mac
  • Browser Chrome 97
  • Time zone: EST
@BePo65
Copy link
Contributor

BePo65 commented May 24, 2022

Neither moment nor dayjs have a parsing token dddd; so parsing with a format of dddd, MMMM D, YYYY h:mm A creates an invalid date (see also issue #1789).

So perhaps this should be a feature request.

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

2 participants