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

Month Abbreviations improvement #914

Closed
eslepova opened this issue May 25, 2020 · 8 comments
Closed

Month Abbreviations improvement #914

eslepova opened this issue May 25, 2020 · 8 comments

Comments

@eslepova
Copy link

eslepova commented May 25, 2020

Hi,

We moved from moment to dayjs a few months ago. And everything is perfect except for one thing: declension of months.

In moment we have:
moment.updateLocale('en', { monthsShort : { format: 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_'), standalone: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_') } }); (https://momentjs.com/docs/#/customization/month-abbreviations/)

Do you have plans to add it?

@eslepova eslepova changed the title Month Abbreviations improvements Month Abbreviations improvement May 25, 2020
@iamkun
Copy link
Owner

iamkun commented May 25, 2020

Of course.

Just check UpdateLocale plugin here https://day.js.org/docs/en/customization/customization

@eslepova
Copy link
Author

Do you mean you will add it sometime?

@iamkun
Copy link
Owner

iamkun commented May 25, 2020

@eslepova we support this . updateLocale already. Just check our website for more detail.

@eslepova
Copy link
Author

eslepova commented May 25, 2020

Yes, but it allows us to add only one monthsShort setting, but moment has 2 settings for monthsShort - format and standalone.
Some languages like Russian have different ways of spelling short months depends of declension. Like "май" and "мая". Both of them are monthsShort.

dayjs('2020-05-25').format('MMM') should return 'май'
dayjs('2020-05-25').format('D MMM') should return '25 мая', but it returns '25 май'

@iamkun
Copy link
Owner

iamkun commented May 25, 2020

You can check here as a reference. https://github.com/iamkun/dayjs/blob/dev/src/locale/ru.js#L39

monthsShort also accepts a function

@iamkun
Copy link
Owner

iamkun commented May 25, 2020

Besides, tested dayjs gives the correct result as you mentioned above.
Screen Shot 2020-05-25 at 6 01 16 PM
https://runkit.com/embed/ai6s8h4zfcbr

@eslepova
Copy link
Author

So ru.js already has everything inside it, and I don't have to add 'monthsShort' manually, which it is used to be in the project. Now I understand, thanks a lot!
The reason for the problem was that monthsShort was overwritten in the project.

It would be nice if you put in doc https://day.js.org/docs/en/customization/customization example that monthsShort can be a function.

Thanks a lot again!

@iamkun
Copy link
Owner

iamkun commented May 25, 2020

doc updated thanks.

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