Skip to content

Commit

Permalink
fix #873 Calendar - set first day of week in accordance with DateTime…
Browse files Browse the repository at this point in the history
…FormatInfo
  • Loading branch information
vegegoku committed Nov 2, 2023
1 parent c678565 commit 7aac106
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 0 additions & 6 deletions domino-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,8 @@

<cssExcludes>
<cssExclude>domino-ui.css</cssExclude>
<!-- <cssExclude>domino-ui-domino-ui-colors.css</cssExclude>-->
<cssExclude>loaders/domino-ui-waitMe.css</cssExclude>
<!-- <cssExclude>domino-ui-grid.css</cssExclude>-->
<!-- <cssExclude>material-icons.css</cssExclude>-->
<cssExclude>**/*.min.css</cssExclude>
<!-- <cssExclude>**/themes/*.css</cssExclude>-->
<!-- <cssExclude>domino-ui-waves.css</cssExclude>-->
<!-- <cssExclude>domino-ui-style.css</cssExclude>-->
</cssExcludes>

<webappSourceDir>${build.directory}/classes</webappSourceDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private void setDate(Date date) {

private void updateView() {
this.root.clearElement();
int firstDayOfTheWeek = this.calendar.getDateTimeFormatInfo().firstDayOfTheWeek();
Date tempDate = new Date(this.date.getYear(), this.date.getMonth(), 1);

int monthFirstDay = tempDate.getDay() == 0 ? 7 : tempDate.getDay();
Expand All @@ -85,17 +86,26 @@ private void updateView() {
.addCss(dui_month_days_header)
.apply(
daysHeader -> {
for (int i = 0; i < 7; i++) {
daysHeader.appendChild(WeekDayHeader.create(this.calendar, i));
int index = firstDayOfTheWeek;
while (index != -1) {
daysHeader.appendChild(WeekDayHeader.create(this.calendar, index));
index = index + 1;
if (index > 6) {
index = 0;
}
if (index == firstDayOfTheWeek) {
index = -1;
}
}
}));
this.monthData = new MonthData(this.date);
MonthData monthBefore = monthData.getMonthBefore();
MonthData monthAfter = monthData.getMonthAfter();

int diff = monthFirstDay + 1;
int offset = Math.abs(monthFirstDay - firstDayOfTheWeek);
int diff = offset + 1;
int[] currentDaysCounter = new int[] {0};
int[] monthBeforeDaysCounter = new int[] {monthBefore.getDaysCount() - monthFirstDay + 1};
int[] monthBeforeDaysCounter = new int[] {monthBefore.getDaysCount() - offset + 1};
int[] monthAfterDaysCounter = new int[] {1};

int[] index = new int[] {0};
Expand All @@ -107,7 +117,7 @@ private void updateView() {
daysRow -> {
for (int day = 0; day < 7; day++) {
CalendarDay calendarDay;
if (index[0] < monthFirstDay) {
if (index[0] < offset) {
calendarDay =
CalendarDay.create(
this.calendar,
Expand All @@ -118,7 +128,7 @@ private void updateView() {
day,
false);
monthBeforeDaysCounter[0] = monthBeforeDaysCounter[0] + 1;
} else if (index[0] >= monthFirstDay
} else if (index[0] >= offset
&& index[0] < (monthData.getDaysCount() + diff - 1)) {
calendarDay =
CalendarDay.create(
Expand Down

0 comments on commit 7aac106

Please sign in to comment.