Why moment.weekdays() returns days starting with Sunday when I specified that first day is Monday?

我们两清 提交于 2019-12-31 04:53:04

问题


I set the locale to 'ro' and now weekdays are in romanian. But, I also set the

week : {
    dow : 1
}

and moment.weekdays() returns days as in 'en' starting with Sunday. Why is this happening?


回答1:


You have to use moment.weekdays(true);

As the docs states:

As of 2.13.0 you can pass a bool as the first parameter of the weekday functions. If true, the weekdays will be returned in locale specific order. For instance, in the Arabic locale, Saturday is the first day of the week

Here a live example:

moment.locale('ro');
// duminică to sâmbătă
console.log(moment.weekdays());
// locale aware: luni to duminică
console.log(moment.weekdays(true));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>


来源:https://stackoverflow.com/questions/43520233/why-moment-weekdays-returns-days-starting-with-sunday-when-i-specified-that-fi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!