Commit d0a042fd authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fixed prior month numbers when viewing January, fixes #94

parent dc7ec4b0
Pipeline #100372 passed with stage
in 5 minutes and 9 seconds
......@@ -3,6 +3,7 @@
#include "monthmodel.h"
#include <QDate>
#include <QDebug>
#include <QRandomGenerator>
struct MonthModel::Private {
......@@ -153,8 +154,8 @@ QVariant MonthModel::data(const QModelIndex &index, int role) const
day = row - daysInMonth - prefix + 1;
} else {
// Previous month
year = d->month > 0 ? d->year : d->year - 1;
month = d->month > 0 ? d->month - 1 : d->calendar.monthsInYear(year) - 1;
year = d->month > 1 ? d->year : d->year - 1;
month = d->month > 1 ? d->month - 1 : d->calendar.monthsInYear(year);
int daysInPreviousMonth = d->calendar.daysInMonth(month, year);
day = daysInPreviousMonth - prefix + row + 1;
}
......
Markdown is supported
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