Skip to content
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

Configurable first day of week #379

Open
kitce opened this issue Jun 24, 2024 · 0 comments
Open

Configurable first day of week #379

kitce opened this issue Jun 24, 2024 · 0 comments

Comments

@kitce
Copy link

kitce commented Jun 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant