QDTP: minor fixes to handling of two-digit years
Although the days in month for a year might be affected by century (if last two digits are 00), actualDate() has at least set the year to its best guess, which will give the right days in the month at least 99% of the time. So take year into account if either year field is set. Adjust a comment's position so that it's clear it's referring to the two-digit case, when (at first sight perversely) using 9999 as the field's max value (it's the datum controlled by it that matters, here). Task-number: QTBUG-46843 Change-Id: Iebebe4b2617eb0820ec57398a774b70bf2ae0898 Reviewed-by: Isak Fyksen <isak.fyksen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7d929f13d5
commit
305c8e9cf0
@ -237,9 +237,9 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
|
||||
case MSecSection:
|
||||
return 999;
|
||||
case YearSection2Digits:
|
||||
case YearSection:
|
||||
// sectionMaxSize will prevent people from typing in a larger number in
|
||||
// count == 2 sections; stepBy() will work on real years anyway.
|
||||
case YearSection:
|
||||
return 9999;
|
||||
case MonthSection:
|
||||
return calendar.maximumMonthsInYear();
|
||||
@ -1032,7 +1032,7 @@ static QDate actualDate(QDateTimeParser::Sections known, const QCalendar &calend
|
||||
|
||||
QDate first(year, month, 1, calendar);
|
||||
int last = known & QDateTimeParser::MonthSection
|
||||
? (known & QDateTimeParser::YearSection
|
||||
? (known.testAnyFlag(QDateTimeParser::YearSectionMask)
|
||||
? calendar.daysInMonth(month, year) : calendar.daysInMonth(month))
|
||||
: 0;
|
||||
// We can only fix DOW if we know year as well as month (hence last):
|
||||
|
Loading…
x
Reference in New Issue
Block a user