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