diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-23 18:35:04 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-25 12:48:37 +0200 |
commit | 100e0485572146e903fb96698cf6a5f34dd6c1f6 (patch) | |
tree | f6445aad7791b4d366c372d01df1332e61c019a0 /src/corelib/time | |
parent | e2c6f2ba7ed72195d12e9882c174e59a53317097 (diff) |
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 1f4b237dade9d0d2ed5439e3834ac22985797561.
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>
Diffstat (limited to 'src/corelib/time')
-rw-r--r-- | src/corelib/time/qgregoriancalendar.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/time/qgregoriancalendar.cpp b/src/corelib/time/qgregoriancalendar.cpp index ca3c19b85c..d8e39786fa 100644 --- a/src/corelib/time/qgregoriancalendar.cpp +++ b/src/corelib/time/qgregoriancalendar.cpp @@ -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 |