Fix leap years in calendar

This commit is contained in:
Michael Zanetti 2019-12-15 13:08:44 +01:00
parent 187d306a0b
commit 9d2828bfaf
2 changed files with 4 additions and 4 deletions

View File

@ -96,9 +96,9 @@ ColumnLayout {
property date firstOfMonth: new Date(root.date.getFullYear(), root.date.getMonth(), 1)
property int offset: ((firstOfMonth.getDay() - 1) % 7 + 7) % 7
property bool isLeapYear: false
property int daysInMonth: isLeapYear ? monthModel.get(root.date.getMonth()).leapDays : monthModel.get(root.date.getMonth()).days
property int daysInPreviousMonth: isLeapYear ? monthModel.get((root.date.getMonth() + 11) % 12).leapDays : monthModel.get((root.date.getMonth() + 11) % 12).days
property bool isLeapYear: firstOfMonth.getFullYear() % 4 == 0 && firstOfMonth.getFullYear() % 100 != 0
property int daysInMonth: isLeapYear ? monthModel.get(root.date.getMonth()).leapYearDays : monthModel.get(root.date.getMonth()).days
property int daysInPreviousMonth: isLeapYear ? monthModel.get((root.date.getMonth() + 11) % 12).leapYearDays : monthModel.get((root.date.getMonth() + 11) % 12).days
Repeater {
model: 6 * 7

View File

@ -38,7 +38,7 @@ Page {
RowLayout {
Layout.fillWidth: true
visible: engine.systemController.automaticTimeAvailable
visible: engine.jsonRpcClient.ensureServerVersion("4.1") && engine.systemController.automaticTimeAvailable
Label {
text: qsTr("Set date and time automatically")
Layout.fillWidth: true