Rename calendar methods from m{in,ax} to m{in,ax}imum
Words should not be abbreviated. Split a long line and reflowed some comments in the process. Fixes: QTBUG-78008 Change-Id: I52d75409f02e2cecbed3e94d424617ad594c275b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
978f579a8c
commit
46ec24d2b9
@ -2916,7 +2916,7 @@ static QString rawStandaloneWeekDayName(const QLocaleData *data, const int day,
|
||||
QString QCalendarBackend::monthName(const QLocale &locale, int month, int,
|
||||
QLocale::FormatType format) const
|
||||
{
|
||||
Q_ASSERT(month >= 1 && month <= maxMonthsInYear());
|
||||
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
|
||||
return rawMonthName(localeMonthIndexData()[locale.d->m_data_offset],
|
||||
localeMonthData(), month, format);
|
||||
}
|
||||
@ -2942,7 +2942,7 @@ QString QGregorianCalendar::monthName(const QLocale &locale, int month, int year
|
||||
QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month, int,
|
||||
QLocale::FormatType format) const
|
||||
{
|
||||
Q_ASSERT(month >= 1 && month <= maxMonthsInYear());
|
||||
Q_ASSERT(month >= 1 && month <= maximumMonthsInYear());
|
||||
return rawStandaloneMonthName(localeMonthIndexData()[locale.d->m_data_offset],
|
||||
localeMonthData(), month, format);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ QString QCalendar::name() const
|
||||
in the month, although \c{isDateValid(year, month, day)} might return \c true for
|
||||
some larger values of \c day.
|
||||
|
||||
\sa daysInYear(), monthsInYear(), minDaysInMonth(), maxDaysInMonth()
|
||||
\sa daysInYear(), monthsInYear(), minimumDaysInMonth(), maximumDaysInMonth()
|
||||
*/
|
||||
|
||||
// properties of the calendar
|
||||
@ -296,7 +296,7 @@ int QCalendarBackend::daysInYear(int year) const
|
||||
|
||||
This base implementation returns 12 for any valid year.
|
||||
|
||||
\sa daysInYear(), maxMonthsInYear(), isDateValid()
|
||||
\sa daysInYear(), maximumMonthsInYear(), isDateValid()
|
||||
*/
|
||||
int QCalendarBackend::monthsInYear(int year) const
|
||||
{
|
||||
@ -354,13 +354,14 @@ bool QCalendarBackend::hasYearZero() const
|
||||
This base implementation returns 31, as this is a common case.
|
||||
|
||||
For calendars with intercallary days, although daysInMonth() doesn't include
|
||||
the intercallary days in its count for an individual month, maxDaysInMonth()
|
||||
should include intercallary days, so that it is the maximum value of \c day
|
||||
for which \c{isDateValid(year, month, day)} can be true.
|
||||
the intercallary days in its count for an individual month,
|
||||
maximumDaysInMonth() should include intercallary days, so that it is the
|
||||
maximum value of \c day for which \c{isDateValid(year, month, day)} can be
|
||||
true.
|
||||
|
||||
\sa maxMonthsInYear(), daysInMonth()
|
||||
\sa maximumMonthsInYear(), daysInMonth()
|
||||
*/
|
||||
int QCalendarBackend::maxDaysInMonth() const
|
||||
int QCalendarBackend::maximumDaysInMonth() const
|
||||
{
|
||||
return 31;
|
||||
}
|
||||
@ -370,9 +371,9 @@ int QCalendarBackend::maxDaysInMonth() const
|
||||
|
||||
This base implementation returns 29, as this is a common case.
|
||||
|
||||
\sa maxMonthsInYear(), daysInMonth()
|
||||
\sa maximumMonthsInYear(), daysInMonth()
|
||||
*/
|
||||
int QCalendarBackend::minDaysInMonth() const
|
||||
int QCalendarBackend::minimumDaysInMonth() const
|
||||
{
|
||||
return 29;
|
||||
}
|
||||
@ -382,9 +383,9 @@ int QCalendarBackend::minDaysInMonth() const
|
||||
|
||||
This base implementation returns 12, as this is a common case.
|
||||
|
||||
\sa maxDaysInMonth(), monthsInYear()
|
||||
\sa maximumDaysInMonth(), monthsInYear()
|
||||
*/
|
||||
int QCalendarBackend::maxMonthsInYear() const
|
||||
int QCalendarBackend::maximumMonthsInYear() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
@ -726,7 +727,7 @@ QCalendar::QCalendar(QStringView name)
|
||||
Months are numbered consecutively, starting with 1 for the first month of each
|
||||
year.
|
||||
|
||||
\sa maxDaysInMonth(), minDaysInMonth()
|
||||
\sa maximumDaysInMonth(), minimumDaysInMonth()
|
||||
*/
|
||||
int QCalendar::daysInMonth(int month, int year) const
|
||||
{
|
||||
@ -868,21 +869,21 @@ bool QCalendar::hasYearZero() const
|
||||
/*!
|
||||
Returns the number of days in the longest month in the calendar, in any year.
|
||||
|
||||
\sa daysInMonth(), minDaysInMonth()
|
||||
\sa daysInMonth(), minimumDaysInMonth()
|
||||
*/
|
||||
int QCalendar::maxDaysInMonth() const
|
||||
int QCalendar::maximumDaysInMonth() const
|
||||
{
|
||||
return d ? d->maxDaysInMonth() : 0;
|
||||
return d ? d->maximumDaysInMonth() : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of days in the shortest month in the calendar, in any year.
|
||||
|
||||
\sa daysInMonth(), maxDaysInMonth()
|
||||
\sa daysInMonth(), maximumDaysInMonth()
|
||||
*/
|
||||
int QCalendar::minDaysInMonth() const
|
||||
int QCalendar::minimumDaysInMonth() const
|
||||
{
|
||||
return d ? d->minDaysInMonth() : 0;
|
||||
return d ? d->minimumDaysInMonth() : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -890,9 +891,9 @@ int QCalendar::minDaysInMonth() const
|
||||
|
||||
\sa monthName(), standaloneMonthName(), monthsInYear()
|
||||
*/
|
||||
int QCalendar::maxMonthsInYear() const
|
||||
int QCalendar::maximumMonthsInYear() const
|
||||
{
|
||||
return d ? d->maxMonthsInYear() : 0;
|
||||
return d ? d->maximumMonthsInYear() : 0;
|
||||
}
|
||||
|
||||
// Julian Day conversions:
|
||||
@ -970,12 +971,12 @@ int QCalendar::dayOfWeek(QDate date) const
|
||||
in the specified \a locale; the \a format determines how fully it shall be
|
||||
expressed (i.e. to what extent it is abbreviated).
|
||||
|
||||
\sa standaloneMonthName(), maxMonthsInYear(), dateTimeToString()
|
||||
\sa standaloneMonthName(), maximumMonthsInYear(), dateTimeToString()
|
||||
*/
|
||||
QString QCalendar::monthName(const QLocale &locale, int month, int year,
|
||||
QLocale::FormatType format) const
|
||||
{
|
||||
const int maxMonth = year == Unspecified ? maxMonthsInYear() : monthsInYear(year);
|
||||
const int maxMonth = year == Unspecified ? maximumMonthsInYear() : monthsInYear(year);
|
||||
if (!d || month < 1 || month > maxMonth)
|
||||
return QString();
|
||||
|
||||
@ -999,12 +1000,12 @@ QString QCalendar::monthName(const QLocale &locale, int month, int year,
|
||||
specified \a locale; the \a format determines how fully it shall be expressed
|
||||
(i.e. to what extent it is abbreviated).
|
||||
|
||||
\sa monthName(), maxMonthsInYear(), dateTimeToString()
|
||||
\sa monthName(), maximumMonthsInYear(), dateTimeToString()
|
||||
*/
|
||||
QString QCalendar::standaloneMonthName(const QLocale &locale, int month, int year,
|
||||
QLocale::FormatType format) const
|
||||
{
|
||||
const int maxMonth = year == Unspecified ? maxMonthsInYear() : monthsInYear(year);
|
||||
const int maxMonth = year == Unspecified ? maximumMonthsInYear() : monthsInYear(year);
|
||||
if (!d || month < 1 || month > maxMonth)
|
||||
return QString();
|
||||
|
||||
|
@ -155,9 +155,9 @@ public:
|
||||
bool isSolar() const;
|
||||
bool isProleptic() const;
|
||||
bool hasYearZero() const;
|
||||
int maxDaysInMonth() const;
|
||||
int minDaysInMonth() const;
|
||||
int maxMonthsInYear() const;
|
||||
int maximumDaysInMonth() const;
|
||||
int minimumDaysInMonth() const;
|
||||
int maximumMonthsInYear() const;
|
||||
QString name() const;
|
||||
|
||||
// QDate conversions:
|
||||
|
@ -95,9 +95,9 @@ public:
|
||||
virtual bool isSolar() const = 0;
|
||||
virtual bool isProleptic() const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int maxDaysInMonth() const;
|
||||
virtual int minDaysInMonth() const;
|
||||
virtual int maxMonthsInYear() const;
|
||||
virtual int maximumDaysInMonth() const;
|
||||
virtual int minimumDaysInMonth() const;
|
||||
virtual int maximumMonthsInYear() const;
|
||||
// Julian Day conversions:
|
||||
virtual bool dateToJulianDay(int year, int month, int day, qint64 *jd) const = 0;
|
||||
virtual QCalendar::YearMonthDay julianDayToDate(qint64 jd) const = 0;
|
||||
|
@ -223,21 +223,23 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
|
||||
case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs;
|
||||
#endif
|
||||
case Hour24Section:
|
||||
case Hour12Section: return 23; // this is special-cased in
|
||||
// parseSection. We want it to be
|
||||
// 23 for the stepBy case.
|
||||
case Hour12Section:
|
||||
// This is special-cased in parseSection.
|
||||
// We want it to be 23 for the stepBy case.
|
||||
return 23;
|
||||
case MinuteSection:
|
||||
case SecondSection: return 59;
|
||||
case MSecSection: return 999;
|
||||
case YearSection2Digits:
|
||||
case YearSection: return 9999; // sectionMaxSize will prevent
|
||||
// people from typing in a larger
|
||||
// number in count == 2 sections.
|
||||
// stepBy() will work on real years anyway
|
||||
case MonthSection: return calendar.maxMonthsInYear();
|
||||
case YearSection:
|
||||
// sectionMaxSize will prevent people from typing in a larger number in
|
||||
// count == 2 sections; stepBy() will work on real years anyway.
|
||||
return 9999;
|
||||
case MonthSection: return calendar.maximumMonthsInYear();
|
||||
case DaySection:
|
||||
case DayOfWeekSectionShort:
|
||||
case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth(calendar) : calendar.maxDaysInMonth() ;
|
||||
case DayOfWeekSectionLong:
|
||||
return cur.isValid() ? cur.date().daysInMonth(calendar) : calendar.maximumDaysInMonth();
|
||||
case AmPmSection: return 1;
|
||||
default: break;
|
||||
}
|
||||
@ -615,7 +617,7 @@ int QDateTimeParser::sectionSize(int sectionIndex) const
|
||||
int QDateTimeParser::sectionMaxSize(Section s, int count) const
|
||||
{
|
||||
#if QT_CONFIG(textdate)
|
||||
int mcount = calendar.maxMonthsInYear();
|
||||
int mcount = calendar.maximumMonthsInYear();
|
||||
#endif
|
||||
|
||||
switch (s) {
|
||||
@ -1291,9 +1293,9 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
||||
}
|
||||
|
||||
if (!calendar.isDateValid(year, month, day)) {
|
||||
if (day <= calendar.maxDaysInMonth())
|
||||
if (day <= calendar.maximumDaysInMonth())
|
||||
cachedDay = day;
|
||||
if (day > calendar.minDaysInMonth() && calendar.isDateValid(year, month, 1))
|
||||
if (day > calendar.minimumDaysInMonth() && calendar.isDateValid(year, month, 1))
|
||||
needfixday = true;
|
||||
}
|
||||
if (needfixday) {
|
||||
|
@ -102,7 +102,7 @@ int QHijriCalendar::daysInMonth(int month, int year) const
|
||||
return month % 2 == 0 ? 29 : 30;
|
||||
}
|
||||
|
||||
int QHijriCalendar::maxDaysInMonth() const
|
||||
int QHijriCalendar::maximumDaysInMonth() const
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class Q_CORE_EXPORT QHijriCalendar : public QCalendarBackend
|
||||
{
|
||||
public:
|
||||
int daysInMonth(int month, int year = QCalendar::Unspecified) const override;
|
||||
int maxDaysInMonth() const override;
|
||||
int maximumDaysInMonth() const override;
|
||||
int daysInYear(int year) const override;
|
||||
|
||||
bool isLunar() const override;
|
||||
|
@ -72,7 +72,7 @@ int QRomanCalendar::daysInMonth(int month, int year) const
|
||||
return 30 | ((month & 1) ^ (month >> 3));
|
||||
}
|
||||
|
||||
int QRomanCalendar::minDaysInMonth() const
|
||||
int QRomanCalendar::minimumDaysInMonth() const
|
||||
{
|
||||
return 28;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class Q_CORE_EXPORT QRomanCalendar : public QCalendarBackend
|
||||
public:
|
||||
// date queries:
|
||||
int daysInMonth(int month, int year = QCalendar::Unspecified) const override;
|
||||
int minDaysInMonth() const override;
|
||||
int minimumDaysInMonth() const override;
|
||||
// properties of the calendar
|
||||
bool isLunar() const override;
|
||||
bool isLuniSolar() const override;
|
||||
|
@ -2413,7 +2413,7 @@ void QCalendarWidget::showNextMonth()
|
||||
Q_D(const QCalendarWidget);
|
||||
int year = yearShown();
|
||||
int month = monthShown();
|
||||
if (month == d->m_model->m_calendar.maxMonthsInYear()) {
|
||||
if (month == d->m_model->m_calendar.maximumMonthsInYear()) {
|
||||
++year;
|
||||
month = 1;
|
||||
} else {
|
||||
@ -2437,7 +2437,7 @@ void QCalendarWidget::showPreviousMonth()
|
||||
int month = monthShown();
|
||||
if (month == 1) {
|
||||
--year;
|
||||
month = d->m_model->m_calendar.maxMonthsInYear();
|
||||
month = d->m_model->m_calendar.maximumMonthsInYear();
|
||||
} else {
|
||||
--month;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ void tst_QCalendar::checkYear(const QCalendar &cal, int year, bool normal)
|
||||
QVERIFY(moons > 0);
|
||||
QVERIFY(!cal.isDateValid(year, moons + 1, 1));
|
||||
QVERIFY(!cal.isDateValid(year, 0, 1));
|
||||
QVERIFY(moons <= cal.maxMonthsInYear());
|
||||
QVERIFY(moons <= cal.maximumMonthsInYear());
|
||||
|
||||
const int days = cal.daysInYear(year);
|
||||
QVERIFY(days > 0);
|
||||
|
||||
int sum = 0;
|
||||
const int longest = cal.maxDaysInMonth();
|
||||
const int longest = cal.maximumDaysInMonth();
|
||||
for (int i = moons; i > 0; i--) {
|
||||
const int last = cal.daysInMonth(i, year);
|
||||
sum += last;
|
||||
|
Loading…
x
Reference in New Issue
Block a user