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

Wrong loading of plugins/locale breaks the app. #1482

Open
asvny opened this issue May 3, 2021 · 3 comments
Open

Wrong loading of plugins/locale breaks the app. #1482

asvny opened this issue May 3, 2021 · 3 comments

Comments

@asvny
Copy link

asvny commented May 3, 2021

Describe the bug
Loading plugins before and then loading the locale for en breaks the app.

Expected behavior
Should work correctly without any error.

Information

  • Day.js Version - 1.9.6
  • OS: Mac
  • Browser Chrome

Let's say we have code like this

dayjs.extend(advancedFormat);
dayjs.locale(require('dayjs/locale/en'))

// Then when you try to do 
dayjs().format('dddd, MMM Do, YYYY');

It breaks with an error d.ordinal is not a function. It is because there is no ordinal property in en.js file. More specifically this function https://github.com/iamkun/dayjs/blob/dev/src/plugin/advancedFormat/index.js#L6 should be moved to en.js file.

Repro - https://codesandbox.io/s/elegant-christian-hbsr7?file=/src/index.js

Happy to submit a PR.

@asvny
Copy link
Author

asvny commented May 3, 2021

Created a fix for it #1483

@ScoreUnder
Copy link

What is the correct order to load these in? I want to use the AdvancedFormat plugin to display day ordinals but I can't figure out how to avoid the r.ordinal is not a function bug.

@rizowski
Copy link

We are only using the AdvancedFormat plugin and getting the r.ordinal is not a function error. Doesn't state in the documentation that it requires any other plugins for using Do

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

3 participants