jsGanttImproved / jsgantt-improved

Javascript Gantt: fully featured gantt chart component built entirely with JS and CSS. No images or external libs required.
https://jsganttimproved.github.io/jsgantt-improved
Other
483 stars 249 forks source link

Configurable first day of week #379

Open kitce opened 4 months ago

kitce commented 4 months ago

Is your feature request related to a problem? Please describe. I want Sunday to be the first day of the week for "Day" view, instead of Monday

Describe the solution you'd like

gantt.setOptions({
  vFirstDayOfWeek: 0, // 0-6: Sunday to Saturday
  // or
  vFirstDayOfWeek: 'Sunday' // "Sunday" | "Monday"
})

Describe alternatives you've considered I have tried to patch the code in date_utils.js

exports.getMinDate = function (pList, pFormat, pMinDate) {
  ...
  if (pFormat == 'day') {
        vDate.setDate(vDate.getDate() - 1);
-       while (vDate.getDay() % 7 != 1)
+       while (vDate.getDay() % 7 != 0)
            vDate.setDate(vDate.getDate() - 1);
  }
  ...
}

exports.getMaxDate = function (pList, pFormat, pMaxDate) {
  ...
  if (pFormat == 'day') {
        vDate.setDate(vDate.getDate() + 1);
-       while (vDate.getDay() % 7 != 0)
+       while (vDate.getDay() % 7 != 6)
            vDate.setDate(vDate.getDate() + 1);
  }
  ...
}

It seems to work as expected, but I am not sure about the edge cases. and I prefer not to patch the package