Skip to content

Configurable first day of week #379

Open
@kitce

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions