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

question about months name #26

Closed
peymanebrahimi opened this issue Sep 1, 2017 · 8 comments
Closed

question about months name #26

peymanebrahimi opened this issue Sep 1, 2017 · 8 comments

Comments

@peymanebrahimi
Copy link

Hi,
This is not an issue.
I have a question:
What is the use cases of

extend(getPrototypeOf(moment.localeData()),
    { _jMonths: [ "Farvardin"
        , "Ordibehesht"
        , "Khordaad"
        , "Tir"

Because of an issue in angular material 2 datepicker, if your library could set months name in the above code just to Persian names as moment's locale data, it may help on mentioned issue.
Thanks again.

@fingerpich
Copy link
Owner

Hi,
What is the problem with the following code?

moment.locale('fa').format('jMMMM');

@peymanebrahimi
Copy link
Author

As you helped me with this nice and concise function of returning weekDayNames:

    getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
        switch (style) {
            case 'long':
                return jmoment().localeData().weekdays().slice(0);
            case 'short':
                return jmoment().localeData().weekdaysShort().slice(0);
            case 'narrow':
                return jmoment().localeData().weekdaysMin().slice(0);
        }
    }

Is there any similar way to returning months name?
I need a consistent way, by calling localeData()
return jmoment().localeData().months().slice(0); // must return Persian names

@fingerpich
Copy link
Owner

Hi,
you could use the following code

moment().localeData()._jMonths.slice(0);
moment().localeData()._jMonthsShort.slice(0);
moment().locale('fa').localeData()._jMonths.slice(0);

@peymanebrahimi
Copy link
Author

no such functions or properties in typescript.
_jMonths is not available on localeData()

@fingerpich
Copy link
Owner

I will fix it in next version
but for now you can cast and use it

(moment().localeData() as any)._jMonths.slice(0);

@peymanebrahimi
Copy link
Author

Thank you very much. nice of you as always

@AsefDaqiq
Copy link

how can i change the names of the months to Afghanistan's month? is there any way to achieve this functionality?

@fingerpich
Copy link
Owner

You can find it in the moment documents
https://www.tutorialspoint.com/momentjs/momentjs_customization_month_names.htm

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