Verified Commit 95890f55 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fix final month dates in schedule view BUG:461200



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@kde.org>
parent b453fd64
Pipeline #259064 passed with stage
in 2 minutes and 45 seconds
......@@ -23,7 +23,7 @@ QQC2.ScrollView {
property date currentDate: new Date()
property date startDate: DateUtils.getFirstDayOfMonth(currentDate)
readonly property int daysInMonth: new Date(startDate.getFullYear(), startDate.getMonth(), 0).getDate()
readonly property int daysInMonth: new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0).getDate()
readonly property int month: startDate.getMonth()
readonly property int year: startDate.getFullYear()
......@@ -179,11 +179,13 @@ QQC2.ScrollView {
Layout.bottomMargin: -dayColumn.spacing // Remove default spacing, bring week header right down to day square
text: {
let nextDay = DateUtils.getLastDayOfWeek( DateUtils.nextWeek(periodStartDate) );
if (nextDay.getMonth() !== periodStartDate.getMonth()) {
nextDay = new Date(nextDay.getFullYear(), nextDay.getMonth(), 0);
}
const daysToWeekEnd = 6;
const nextDayMaxDiff = (periodStartDate.getDate() - (model.index + 1)) + daysToWeekEnd;
const nextDayMaxDate = periodStartDate.getDate() + nextDayMaxDiff;
const nextDayDate = Math.min(nextDayMaxDate, scrollView.daysInMonth);
const nextDay = new Date(periodStartDate.getFullYear(), periodStartDate.getMonth(), nextDayDate);
return periodStartDate.toLocaleDateString(Qt.locale(), "dddd <b>dd</b>") + "" + nextDay.toLocaleDateString(Qt.locale(), "dddd <b>dd</b> MMMM");
}
visible: Kalendar.Config.showWeekHeaders &&
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment