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
Week Days locale problems #4066
Comments
Hmm, I can't reproduce this. I think you're saying this: moment.locale('en') //=> "en" (I don't have the locale set to zh)
// you're saying this is NOT in the right order
moment.localeData('zh_CN').weekdays(); //=> ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
//but if you change the global locale, then it is
moment.locale('zh_CN'); //=> "zh-cn"
moment.weekdays() //=> ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"] I wouldn't be surprised if it worked like you said it does (the localeData is getting directly at the data, so wouldn't be surprising if it didn't do the reordering, and possibly we just don't have an API for getting the ordered weekdays for a non-globally-set locale). But...aren't those arrays above the same? I don't read or speak Chinese so don't know whether they're in locally-correct order, but unless I'm missing something (always possible when looking at unfamiliar characters) they either both are or both aren't, right? |
It's the same with "en-gb" and "en-us". If my locale is 'en-us' and i want to get the 'en-gb' weekdays, including sorting, i'll be forced to change the locale globally or do some array work to get the sorted weekdays.
But
And there is no
|
Hmm, yeah, I'm calling this a bug. |
An interesting information is that the
returns |
I did some digging. There is a different function that implements As mentioned in the docs, the first is designed to list the current locale's months or weekdays. The second is designed to get information from the locale itself. We could locale-sort the weekdays with the same parameter.
I've put up a PR - let me know what you all think. |
Is there a plan to fix |
@inbalg No, that is correct |
Description of the Issue and Steps to Reproduce:
As in the official document,
moment.locale('zh_CN');
moment.weekdays(true); // lists weekdays Monday-Sunday in Chinese
If true, the weekdays will be returned in locale specific order. But in the case, the moment locale is changed globally.
So if I just want to change the locale locally, I use
moment.localeData('zh_CN').weekdaysShort()
It always lists weekdays from Sunday-Saturday in Chinese (NOT in locale specific order). And I could not provide 'true' value to the function in this case(Causing ERROR).
Please include the values of all variables used.
Environment:
Examples: Chrome 49 on OSX, Internet Explorer 10 on Windows 7, Node.JS 4.4.4 on Ubuntu 16.0.4
Both the browser and the OS are important to us, particularly if you have an unsual environment like an IOT application.
Other information that may be helpful:
If you are reporting an issue, please run the following code in the environment you are using and include the output:
Ensure your issue is isolated to moment. Issues involving third party tools will be closed unless submitted by the tool's author/maintainer.
The text was updated successfully, but these errors were encountered: