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

GanttViewDay - Issue with week numbering when weekStart.getDaysInMonth() - weekStart.getDate() < 3 #274

Open
Theodode opened this issue Nov 10, 2022 · 0 comments

Comments

@Theodode
Copy link

Theodode commented Nov 10, 2022

With the following configuration :

{
      provide: GANTT_GLOBAL_CONFIG,
      useValue: {
        dateFormat: {
          week: `'semaine' w`,
          year: `yyyy`,
          yearQuarter: `'Trimestre' Q yyyy`,
          month: 'LLLL',
          yearMonth: `LLLL yyyy' (semaine' w')'`
        }
      }
 },

In yearMonth view aka DayView, the week numbering is incorrect if the most part of the current week is on the next month.
This year 2022 it occurs on the following weeks (with monday as first weekday) :

  • January 31st
  • March 28th
  • June 30th
  • September 29th
  • November 31st
  • December 28th

All these weeks have less than 3 days before next month. So according "packages/gantt/src/views/day.ts" (line 43) the week is increased by one in order to get next month name upper the week. But next to the month i also wrote the week number (see GANTT_GLOBAL_CONFIG up there). So the printed week number is the next one not the current one.

Expected Behavior :
I expect to get the correct week number, i don't care too much about month name but i think we can make an exception to get both the next month name and the correct week number.

Source of the issue:

class GanttViewDay extends GanttView {

  //....

  getPrimaryDatePoints() {
          const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
          const points = [];
          for (let i = 0; i < weeks.length; i++) {
              const weekStart = new GanttDate(weeks[i]);
              const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
              const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.yearMonth), (this.getCellWidth() * 7) / 2 + i * (this.getCellWidth() * 7), primaryDatePointTop);
              points.push(point);
          }
          return points;
      }

  //....
}
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