Fix firstDayOfWeek bug
Fix firstDayOfWeek bug #21
confirmed this fixes!
Not sure if this line is causing the problem to
https://github.com/sensortower/daterangepicker/blob/master/src/scripts/daterangepicker/config.coffee#L37
if val is null, it set 0 and fire the update, that can be a different value and cause and update on the moment.localeData
myabe we need to used ko.observable(val ? val : moment.localeData().firstDayOfWeek())
Seems like something deeper is broken here: this fix works for Day but doesn't affect Week at all. 🤔
After some deeper investigation we found out that the behavior of the daterangepicker is far from optimal here. It always overwrites the firstDayOfWeek in the moment.js locale data with its own setting, ignoring the default provided by the selected locale.
Thus the proper fix for now is this:
moment.locale('de'); // Example: German
$element.daterangepicker({
// ...
firstDayOfWeek: moment.localeData().firstDayOfWeek(),
// ...
});
This ensures that
- The table of days in the Day and Week view is correct and
- The calendar column headers (weekdays) match their days in the view.
This pull request is not a solution ATM.
Any updates on this matter? Applied the change and indeed it only affects the Days, not working with Weeks view.
firstDayOfWeek : 1 simply shows a wrong calendar (although clicking on them shows a correct date).
I have this issue and can workaround (actually it can be a fix) by manual update moment plugin setting.
