10#if QT_CONFIG(jalalicalendar)
13#if QT_CONFIG(islamiccivilcalendar)
17#include <private/qflatmap_p.h>
60 std::vector<QCalendarBackend *> byId;
72 std::vector<QCalendarBackend *>
82 QAtomicPointer<const QCalendarBackend> gregorianCalendar =
nullptr;
97 void ensurePopulated();
105 byId.resize(ExpectedNumberOfBackends);
106 byName.reserve(ExpectedNumberOfBackends * 2);
137 return backend == gregorianCalendar.loadRelaxed();
194void QCalendarRegistry::ensurePopulated()
204 if (byId[
i] ==
nullptr)
208#if defined(QT_FORCE_ASSERTS) || !defined(QT_NO_DEBUG)
235#ifndef QT_BOOTSTRAPPED
245#if QT_CONFIG(jalalicalendar)
246 case QCalendar::System::Jalali:
251#if QT_CONFIG(islamiccivilcalendar)
252 case QCalendar::System::IslamicCivil:
265 registerBackendLockHeld(backend,
names, system);
266 Q_ASSERT(backend == byId[
size_t(system)]);
283 auto index = size_t(system);
288 backend->setIndex(byId.size());
289 byId.push_back(backend);
290 }
else if (byId[
index] ==
nullptr) {
291 backend->setIndex(
index);
293#if defined(QT_FORCE_ASSERTS) || !defined(QT_NO_DEBUG)
303 byId[
index] = backend;
311 qWarning(
"Cannot register name %ls (already in use) for %ls",
330 return byName.
keys();
363 if (
index >= byId.size())
366 if (
auto backend = byId[
index])
391 auto index = size_t(system);
396 if (
auto backend = byId[
index])
403 if (
auto backend = byId[
index])
406 return registerSystemBackendLockHeld(system);
415 l.reserve(byName.
size());
422 for (
const auto &[
key,
value] : byName) {
423 if (
value == backend)
520 || calendarRegistry->isBeingDestroyed());
539 if (
Q_UNLIKELY(calendarRegistry.isDestroyed()))
542 return calendarRegistry->backendNames(
this);
551void QCalendarBackend::setIndex(
size_t index)
583 if (
Q_LIKELY(!calendarRegistry.isDestroyed()))
584 calendarRegistry->registerCustomBackend(
this,
names);
591 if (
Q_UNLIKELY(calendarRegistry.isDestroyed()))
594 return calendarRegistry->isGregorian(
this);
625#define SAFE_D() const auto d = Q_UNLIKELY(calendarRegistry.isDestroyed()) ? nullptr : d_ptr
872 return QRoundingDown::qMod<7>(jd) + 1;
898 const auto checkOffset = [parts, dow,
this](
int centuries) -> std::optional<qint64> {
900 int year = parts.
year + centuries * 100;
903 year += parts.
year > 0 ? -1 : +1;
915 if (
auto jd = checkOffset(
offset))
918 if (
auto jd = checkOffset(-
offset))
922 return (std::numeric_limits<qint64>::min)();
1037 if (
Q_UNLIKELY(calendarRegistry.isDestroyed()))
1040 return calendarRegistry->availableCalendars();
1055 if (
Q_UNLIKELY(calendarRegistry.isDestroyed()))
1058 return calendarRegistry->fromName(
name);
1072 if (
Q_UNLIKELY(calendarRegistry.isDestroyed() || !
id.isValid()))
1075 return calendarRegistry->fromIndex(
id.
index());
1093 return calendarRegistry->fromEnum(system);
1104 if (
Q_UNLIKELY(calendarRegistry.isDestroyed()))
1107 return calendarRegistry->gregorian();
1269 return d ?
d->daysInMonth(month, year) : 0;
1280 return d ?
d->daysInYear(year) : 0;
1294 return d ? year ==
Unspecified ?
d->maximumMonthsInYear() :
d->monthsInYear(year) : 0;
1308 return d &&
d->isDateValid(year, month, day);
1320 return d &&
d->isGregorian();
1335 return d &&
d->isLeapYear(year);
1346 return d &&
d->isLunar();
1359 return d &&
d->isLuniSolar();
1371 return d &&
d->isSolar();
1386 return d &&
d->isProleptic();
1417 return d &&
d->hasYearZero();
1428 return d ?
d->maximumDaysInMonth() : 0;
1439 return d ?
d->minimumDaysInMonth() : 0;
1450 return d ?
d->maximumMonthsInYear() : 0;
1473 return d &&
d->dateToJulianDay(year, month, day, &jd)
1564 if (!
d || month < 1 || month > maxMonth)
1567 return d->monthName(locale, month, year,
format);
1594 if (!
d || month < 1 || month > maxMonth)
1597 return d->standaloneMonthName(locale, month, year,
format);
1668 return d ?
d->dateTimeToString(
format, datetime, dateOnly, timeOnly, locale) :
QString();
1685#ifndef QT_BOOTSTRAPPED
1686#include "moc_qcalendar.cpp"
static Q_CORE_EXPORT int compare(QAnyStringView lhs, QAnyStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Compares the string view lhs with the string view rhs and returns a negative integer if lhs is less t...
T fetchAndStoreRelease(T newValue) noexcept
void storeRelaxed(T newValue) noexcept
T loadAcquire() const noexcept
void storeRelease(T newValue) noexcept
T loadRelaxed() const noexcept
Type fetchAndStoreRelease(Type newValue) noexcept
void storeRelease(Type newValue) noexcept
The QCalendarBackend class provides basic calendaring functions.
virtual int daysInMonth(int month, int year=QCalendar::Unspecified) const =0
Returns number of days in the month number month, in year year.
QCalendar::System calendarSystem() const
The calendar system of this calendar.
virtual bool isProleptic() const
Returns true if this calendar is a proleptic calendar.
virtual ~QCalendarBackend()
Destroys the calendar backend.
virtual bool hasYearZero() const
Returns true if year number 0 is considered a valid year in this calendar.
QCalendar::SystemId calendarId() const
virtual int dayOfWeek(qint64 jd) const
Returns the day of the week for the given Julian Day Number jd.
static QStringList availableCalendars()
Returns a list of names of the available calendar systems.
virtual bool isLeapYear(int year) const =0
Returns true if the specified year is a leap year for this calendar.
virtual int minimumDaysInMonth() const
Returns the minimum number of days in any valid month of any valid year.
virtual bool dateToJulianDay(int year, int month, int day, qint64 *jd) const =0
Computes the Julian day number corresponding to the specified year, month, and day.
virtual int maximumDaysInMonth() const
Returns the maximum number of days in a month for any year.
virtual int monthsInYear(int year) const
Returns the total number of months in the year number year.
virtual QString name() const =0
Returns the primary name of the calendar.
virtual int daysInYear(int year) const
Returns the total number of days in the year number year.
QStringList names() const
Returns list of names this backend was registered with.
virtual qint64 matchCenturyToWeekday(const QCalendar::YearMonthDay &parts, int dow) const
QCalendar::SystemId registerCustomBackend(const QStringList &names)
Register this backend as a custom backend.
virtual int maximumMonthsInYear() const
Returns the maximum number of months possible in any year.
virtual bool isDateValid(int year, int month, int day) const
Returns true if the date specified by year, month, and day is valid for this calendar; otherwise retu...
constexpr bool isValid() const noexcept
Returns true if this is a valid calendar implementation identifier, false otherwise.
constexpr size_t index() const noexcept
bool isGregorian() const
Returns true if this calendar object is the Gregorian calendar object used as default calendar by oth...
QDate dateFromParts(int year, int month, int day) const
System
This enumerated type is used to specify a choice of calendar system.
int minimumDaysInMonth() const
Returns the number of days in the shortest month in the calendar, in any year.
bool isDateValid(int year, int month, int day) const
Returns true precisely if the given year, month, and day specify a valid date in this calendar.
QString standaloneMonthName(const QLocale &locale, int month, int year=Unspecified, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised standalone name for a month.
static QStringList availableCalendars()
Returns a list of names of the available calendar systems.
bool isLunar() const
Returns true if this calendar is a lunar calendar.
QDate matchCenturyToWeekday(const YearMonthDay &parts, int dow) const
QString dateTimeToString(QStringView format, const QDateTime &datetime, QDate dateOnly, QTime timeOnly, const QLocale &locale) const
Returns a string representing a given date, time or date-time.
QString name() const
The primary name of this calendar.
QString monthName(const QLocale &locale, int month, int year=Unspecified, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised name for a month.
YearMonthDay partsFromDate(QDate date) const
Converts a QDate to a year, month, and day of the month.
int maximumMonthsInYear() const
Returns the largest number of months that any year may contain.
int maximumDaysInMonth() const
Returns the number of days in the longest month in the calendar, in any year.
bool hasYearZero() const
Returns true if this calendar has a year zero.
int monthsInYear(int year) const
Returns the number of months in the given year.
int dayOfWeek(QDate date) const
Returns the day of the week number for the given date.
bool isLuniSolar() const
Returns true if this calendar is luni-solar.
bool isLeapYear(int year) const
Returns true if the given year is a leap year.
QString standaloneWeekDayName(const QLocale &locale, int day, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised standalone name for a day of the week.
bool isProleptic() const
Returns true if this calendar is proleptic.
int daysInMonth(int month, int year=Unspecified) const
Returns the number of days in the given month of the given year.
int daysInYear(int year) const
Returns the number of days in the given year.
bool isSolar() const
Returns true if this calendar is solar.
QString weekDayName(const QLocale &locale, int day, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised name for a day of the week.
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
constexpr qint64 toJulianDay() const
Converts the date to a Julian day.
static constexpr QDate fromJulianDay(qint64 jd_)
Converts the Julian day jd to a QDate.
const key_container_type & keys() const noexcept
T value(const Key &key, const T &defaultValue) const
std::pair< iterator, bool > try_emplace(const Key &key, Args &&...args)
size_type size() const noexcept
The QGregorianCalendar class implements the Gregorian calendar.
static QStringList nameList()
Implements a commonly-used computed version of the Islamic calendar.
static QStringList nameList()
The QJalaliCalendar class provides Jalali (Hijri Shamsi) calendar system implementation.
static QStringList nameList()
The QJulianCalendar class provides Julian calendar system implementation.
static QStringList nameList()
The QMilankovicCalendar class provides Milanković calendar system implementation.
static QStringList nameList()
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtCore \reentrant
const QCalendarBackend * fromEnum(QCalendar::System system)
QStringList availableCalendars()
const QCalendarBackend * fromName(QAnyStringView name)
void registerCustomBackend(QCalendarBackend *backend, const QStringList &names)
bool isGregorian(const QCalendarBackend *backend) const
bool isBeingDestroyed() const
const QCalendarBackend * fromIndex(size_t index)
QStringList backendNames(const QCalendarBackend *backend)
const QCalendarBackend * gregorian()
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define QT_WARNING_DISABLE_CLANG(text)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
#define qUtf16Printable(string)
bool operator()(QAnyStringView lhs, QAnyStringView rhs) const