daterangepicker icon indicating copy to clipboard operation
daterangepicker copied to clipboard

Fix firstDayOfWeek bug

Open g1mn opened this issue 8 years ago • 6 comments

Fix firstDayOfWeek bug #21

g1mn avatar Mar 28 '17 19:03 g1mn

confirmed this fixes!

tom-spalding avatar Mar 28 '17 20:03 tom-spalding

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())

nmocruz avatar Jul 04 '17 14:07 nmocruz

Seems like something deeper is broken here: this fix works for Day but doesn't affect Week at all. 🤔

mbrodala avatar Feb 01 '18 11:02 mbrodala

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

  1. The table of days in the Day and Week view is correct and
  2. The calendar column headers (weekdays) match their days in the view.

This pull request is not a solution ATM.

mbrodala avatar Feb 02 '18 11:02 mbrodala

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).

joehannouch avatar Dec 18 '18 15:12 joehannouch

I have this issue and can workaround (actually it can be a fix) by manual update moment plugin setting.

image

duyanhth avatar Jul 17 '19 11:07 duyanhth