Use qMod(, 7) rather than % 7 in day-of-week calculation
Otherwise, for the first day of a negative year, we'd get an invalid
day of the week (required to be in the range 1 through 7).
This is a follow-up to commit 1f4b237dad.
Change-Id: If1afcd42065c26d5fa5799b0cd47921a3d424dc8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
parent
e2c6f2ba7e
commit
100e048557
|
|
@ -144,7 +144,7 @@ int QGregorianCalendar::yearStartWeekDay(int year)
|
|||
{
|
||||
// Equivalent to weekDayOfJulian(julianForParts({year, 1, 1})
|
||||
const int y = year - (year < 0 ? 800 : 801);
|
||||
return (y + qDiv(y, 4) - qDiv(y, 100) + qDiv(y, 400)) % 7 + 1;
|
||||
return qMod(y + qDiv(y, 4) - qDiv(y, 100) + qDiv(y, 400), 7) + 1;
|
||||
}
|
||||
|
||||
QCalendar::YearMonthDay QGregorianCalendar::julianDayToDate(qint64 jd) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue