QtBase  v6.3.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
QCalendarBackend Class Referenceabstract

#include <qcalendarbackend_p.h>

Inheritance diagram for QCalendarBackend:
Inheritance graph
[legend]

Public Member Functions

virtual ~QCalendarBackend ()
 
virtual QString name () const =0
 
QStringList names () const
 
QCalendar::System calendarSystem () const
 
QCalendar::SystemId calendarId () const
 
virtual int daysInMonth (int month, int year=QCalendar::Unspecified) const =0
 
virtual int daysInYear (int year) const
 
virtual int monthsInYear (int year) const
 
virtual bool isDateValid (int year, int month, int day) const
 
virtual bool isLeapYear (int year) const =0
 
virtual bool isLunar () const =0
 
virtual bool isLuniSolar () const =0
 
virtual bool isSolar () const =0
 
virtual bool isProleptic () const
 
virtual bool hasYearZero () const
 
virtual int maximumDaysInMonth () const
 
virtual int minimumDaysInMonth () const
 
virtual int maximumMonthsInYear () const
 
virtual bool dateToJulianDay (int year, int month, int day, qint64 *jd) const =0
 
virtual QCalendar::YearMonthDay julianDayToDate (qint64 jd) const =0
 
virtual int dayOfWeek (qint64 jd) const
 
virtual QString monthName (const QLocale &locale, int month, int year, QLocale::FormatType format) const
 
virtual QString standaloneMonthName (const QLocale &locale, int month, int year, QLocale::FormatType format) const
 
virtual QString weekDayName (const QLocale &locale, int day, QLocale::FormatType format) const
 
virtual QString standaloneWeekDayName (const QLocale &locale, int day, QLocale::FormatType format) const
 
virtual QString dateTimeToString (QStringView format, const QDateTime &datetime, QDate dateOnly, QTime timeOnly, const QLocale &locale) const
 
bool isGregorian () const
 
QCalendar::SystemId registerCustomBackend (const QStringList &names)
 

Static Public Member Functions

static QStringList availableCalendars ()
 

Protected Member Functions

virtual const QCalendarLocalelocaleMonthIndexData () const =0
 
virtual const char16_t * localeMonthData () const =0
 

Friends

class QCalendar
 
class QtPrivate::QCalendarRegistry
 

Detailed Description

Since
5.14

\inmodule QtCore

Definition at line 94 of file qcalendarbackend_p.h.

Constructor & Destructor Documentation

◆ ~QCalendarBackend()

QCalendarBackend::~QCalendarBackend ( )
virtual

Destroys the calendar backend.

Each calendar backend, once instantiated and successfully registered by ID, shall exist until it is destroyed by the registry. Destroying a successfully-registered backend otherwise may leave existing QCalendar instances referencing the destroyed calendar, with undefined results.

If a backend has not been registered it may safely be deleted.

See also
calendarId()

Definition at line 550 of file qcalendar.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ availableCalendars()

QStringList QCalendarBackend::availableCalendars ( )
static

Returns a list of names of the available calendar systems. Any QCalendarBackend sub-class must be registered before being exposed to Date and Time APIs.

See also
fromName()

Definition at line 1013 of file qcalendar.cpp.

Here is the caller graph for this function:

◆ calendarId()

QCalendar::SystemId QCalendarBackend::calendarId ( ) const
inline
Since
6.2

Each backend is allocated an ID when successfully registered. A backend whose calendarId() has isValid() {false} has not been registered; it also cannot be used, as it is not known to any of the available ways to create a QCalendar.

See also
calendarSystem(), fromId()

Definition at line 106 of file qcalendarbackend_p.h.

Here is the caller graph for this function:

◆ calendarSystem()

QCalendar::System QCalendarBackend::calendarSystem ( ) const

The calendar system of this calendar.

See also
fromEnum(), calendarId()

Definition at line 646 of file qcalendar.cpp.

Here is the call graph for this function:

◆ dateTimeToString()

QString QCalendarBackend::dateTimeToString ( QStringView  format,
const QDateTime datetime,
QDate  dateOnly,
QTime  timeOnly,
const QLocale locale 
) const
virtual

Returns a string representing a given date, time or date-time.

If datetime is specified and valid, it is used and both date and time format tokens are converted to appropriate representations of the parts of the datetime. Otherwise, if dateOnly is valid, only date format tokens are converted; else, if timeOnly is valid, only time format tokens are converted. If none are valid, an empty string is returned.

The specified locale influences how some format tokens are converted; for example, when substituting day and month names and their short-forms. For the supported formatting tokens, see QDate::toString() and QTime::toString(). As described above, the provided date, time and date-time determine which of these tokens are recognized: where these appear in format they are replaced by data. Any text in format not recognized as a format token is copied verbatim into the result string.

See also
QDate::toString(), QTime::toString(), QDateTime::toString()

Definition at line 3319 of file qlocale.cpp.

Here is the call graph for this function:

◆ dateToJulianDay()

bool QCalendarBackend::dateToJulianDay ( int  year,
int  month,
int  day,
qint64 jd 
) const
pure virtual

Computes the Julian day number corresponding to the specified year, month, and day. Returns true and sets jd if there is such a date in this calendar; otherwise, returns false.

See also
QCalendar::partsFromDate(), julianDayToDate()

Implemented in QMilankovicCalendar, QJulianCalendar, QJalaliCalendar, QIslamicCivilCalendar, and QGregorianCalendar.

◆ dayOfWeek()

int QCalendarBackend::dayOfWeek ( qint64  jd) const
virtual

Returns the day of the week for the given Julian Day Number jd.

This is 1 for Monday through 7 for Sunday.

Calendars with intercallary days may return larger values for these intercallary days. They should avoid using 0 for any special purpose (it is already used in QDate::dayOfWeek() to mean an invalid date). The calendar should treat the numbers used as an enum, whose values need not be contiguous, nor need they follow closely from the 1 through 7 of the usual returns. It suffices that weekDayName() can recognize each such number as identifying a distinct name, that it returns to identify the particular intercallary day.

This base implementation uses the day-numbering that various calendars have borrowed off the Hebrew calendar.

See also
weekDayName(), standaloneWeekDayName(), QDate::dayOfWeek()

Definition at line 898 of file qcalendar.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ daysInMonth()

int QCalendarBackend::daysInMonth ( int  month,
int  year = QCalendar::Unspecified 
) const
pure virtual

Returns number of days in the month number month, in year year.

An implementation should return 0 if the given year had no such month. If year is QCalendar::Unspecified, return the usual number of days for the month, in those years that include it.

Calendars with intercallary days may represent these as extra days of the preceding month, or as short months separate from the usual ones. In the former case, daysInMonth(month, year) should be the number of ordinary days in the month, although {isDateValid(year, month, day)} might return true for some larger values of day.

See also
daysInYear(), monthsInYear(), minimumDaysInMonth(), maximumDaysInMonth()

Implemented in QRomanCalendar, QJalaliCalendar, and QHijriCalendar.

Here is the caller graph for this function:

◆ daysInYear()

int QCalendarBackend::daysInYear ( int  year) const
virtual

Returns the total number of days in the year number year. Returns zero if there is no such year in this calendar.

This base implementation returns 366 for leap years and 365 for ordinary years.

See also
monthsInYear(), daysInMonth(), isLeapYear()

Reimplemented in QHijriCalendar.

Definition at line 750 of file qcalendar.cpp.

Here is the call graph for this function:

◆ hasYearZero()

bool QCalendarBackend::hasYearZero ( ) const
virtual

Returns true if year number 0 is considered a valid year in this calendar. Otherwise returns false.

See also
isDateValid(), isProleptic()

Definition at line 808 of file qcalendar.cpp.

Here is the caller graph for this function:

◆ isDateValid()

bool QCalendarBackend::isDateValid ( int  year,
int  month,
int  day 
) const
virtual

Returns true if the date specified by year, month, and day is valid for this calendar; otherwise returns false. For example, the date 2018-04-19 is valid for the Gregorian calendar, but 2018-16-19 and 2018-04-38 are invalid.

Calendars with intercallary days may represent these as extra days of the preceding month or as short months separate from the usual ones. In the former case, a day value greater than {daysInMonth({month}, {year})} may be valid.

See also
daysInMonth(), monthsInYear()

Definition at line 781 of file qcalendar.cpp.

Here is the call graph for this function:

◆ isGregorian()

bool QCalendarBackend::isGregorian ( ) const

Definition at line 622 of file qcalendar.cpp.

◆ isLeapYear()

bool QCalendarBackend::isLeapYear ( int  year) const
pure virtual

Returns true if the specified year is a leap year for this calendar.

See also
daysInYear(), isDateValid()

Implemented in QMilankovicCalendar, QJulianCalendar, QJalaliCalendar, QIslamicCivilCalendar, and QGregorianCalendar.

Here is the caller graph for this function:

◆ isLunar()

bool QCalendarBackend::isLunar ( ) const
pure virtual

Returns true if this calendar is a lunar calendar. Otherwise returns false.

A lunar calendar is a calendar based upon the monthly cycles of the Moon's phases (synodic months). This contrasts with solar calendars, whose annual cycles are based only upon the solar year.

See also
isLuniSolar(), isSolar(), isProleptic()

Implemented in QRomanCalendar, QJalaliCalendar, and QHijriCalendar.

◆ isLuniSolar()

bool QCalendarBackend::isLuniSolar ( ) const
pure virtual

Returns true if this calendar is a lunisolar calendar. Otherwise returns false.

A lunisolar calendar is a calendar whose date indicates both the moon phase and the time of the solar year.

See also
isLunar(), isSolar(), isProleptic()

Implemented in QRomanCalendar, QJalaliCalendar, and QHijriCalendar.

◆ isProleptic()

bool QCalendarBackend::isProleptic ( ) const
virtual

Returns true if this calendar is a proleptic calendar. Otherwise returns false.

A proleptic calendar results from allowing negative year numbers to indicate years before the nominal start of the calendar system.

See also
isLuniSolar(), isSolar(), isLunar(), hasYearZero()

Definition at line 796 of file qcalendar.cpp.

Here is the caller graph for this function:

◆ isSolar()

bool QCalendarBackend::isSolar ( ) const
pure virtual

Returns true if this calendar is a solar calendar. Otherwise returns false.

A solar calendar is a calendar whose dates indicate the season or almost equivalently the apparent position of the sun relative to the fixed stars. The Gregorian calendar, widely accepted as standard in the world, is an example of solar calendar.

See also
isLuniSolar(), isLunar(), isProleptic()

Implemented in QRomanCalendar, QJalaliCalendar, and QHijriCalendar.

◆ julianDayToDate()

QCalendar::YearMonthDay QCalendarBackend::julianDayToDate ( qint64  jd) const
pure virtual

Computes the year, month, and day in this calendar for the given Julian day number jd. If the given day falls outside this calendar's scope (e.g. before the start-date of a non-proleptic calendar), the returned structure's isValid() is false; otherwise, its year, month, and day fields provide this calendar's description of the date.

See also
QCalendar::dateFromParts(), dateToJulianDay()

Implemented in QMilankovicCalendar, QJulianCalendar, QJalaliCalendar, QIslamicCivilCalendar, and QGregorianCalendar.

Here is the caller graph for this function:

◆ localeMonthData()

virtual const char16_t* QCalendarBackend::localeMonthData ( ) const
protectedpure virtual

◆ localeMonthIndexData()

virtual const QCalendarLocale* QCalendarBackend::localeMonthIndexData ( ) const
protectedpure virtual

◆ maximumDaysInMonth()

int QCalendarBackend::maximumDaysInMonth ( ) const
virtual

Returns the maximum number of days in a month for any year.

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, maximumDaysInMonth() should include intercallary days, so that it is the maximum value of day for which {isDateValid(year, month, day)} can be true.

See also
maximumMonthsInYear(), daysInMonth()

Reimplemented in QHijriCalendar.

Definition at line 826 of file qcalendar.cpp.

◆ maximumMonthsInYear()

int QCalendarBackend::maximumMonthsInYear ( ) const
virtual

Returns the maximum number of months possible in any year.

This base implementation returns 12, as this is a common case.

See also
maximumDaysInMonth(), monthsInYear()

Definition at line 850 of file qcalendar.cpp.

Here is the caller graph for this function:

◆ minimumDaysInMonth()

int QCalendarBackend::minimumDaysInMonth ( ) const
virtual

Returns the minimum number of days in any valid month of any valid year.

This base implementation returns 29, as this is a common case.

See also
maximumMonthsInYear(), daysInMonth()

Reimplemented in QRomanCalendar.

Definition at line 838 of file qcalendar.cpp.

◆ monthName()

QString QCalendarBackend::monthName ( const QLocale locale,
int  month,
int  year,
QLocale::FormatType  format 
) const
virtual

Returns the name of the specified month in the given year for the chosen locale, using the given format to determine how complete the name is.

If year is Unspecified, return the name for the month that usually has this number within a typical year. Calendars with a leap month that isn't always the last may need to take account of the year to map the month number to the particular year's month with that number.

Note
Backends for which CLDR provides data can configure the default implementation of the two month name look-up methods by arranging for localeMonthIndexData() and localeMonthData() to provide access to the CLDR data (see cldr2qlocalexml.py, qlocalexml2cpp.py and existing backends). Conversely, backends that override both month name look-up methods need not return anything meaningful from localeMonthIndexData() or localeMonthData().
See also
standaloneMonthName(), QLocale::monthName()

Reimplemented in QGregorianCalendar.

Definition at line 2981 of file qlocale.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monthsInYear()

int QCalendarBackend::monthsInYear ( int  year) const
virtual

Returns the total number of months in the year number year. Returns zero if there is no such year in this calendar.

This base implementation returns 12 for any valid year.

See also
daysInYear(), maximumMonthsInYear(), isDateValid()

Definition at line 763 of file qcalendar.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

QString QCalendarBackend::name ( ) const
pure virtual

Returns the primary name of the calendar.

Implemented in QMilankovicCalendar, QJulianCalendar, QJalaliCalendar, QIslamicCivilCalendar, and QGregorianCalendar.

Here is the caller graph for this function:

◆ names()

QStringList QCalendarBackend::names ( ) const

Returns list of names this backend was registered with.

The list is a subset of the names passed to registerCustomBackend(). Some names passed during the registration may not be associated with a backend if they were claimed by another backend first.

See also
registerCustomBackend()

Definition at line 570 of file qcalendar.cpp.

Here is the caller graph for this function:

◆ registerCustomBackend()

QCalendar::SystemId QCalendarBackend::registerCustomBackend ( const QStringList names)

Register this backend as a custom backend.

The backend should not already be registered. This method should only be called on objects that are completely initialized because they become available to other threads immediately. In particular, this function should not be called from backend constructors.

The backend is also registered by names passed in names. Only the names that are not already registered are associated with the backend. The name matching is case-insensitive. The list of names associated with the backend can be queried using names() method after successful registration.

Returns the new ID assigned to this backend. If its isValid() is true, the calendar registry has taken ownership of the object; this ID can then be used to create QCalendar instances. Otherwise, registration failed and the caller is responsible for destruction of the backend, which shall not be available for use by QCalendar. Failure should normally only happen if registration is attempted during program termination.

See also
names()

Definition at line 612 of file qcalendar.cpp.

Here is the call graph for this function:

◆ standaloneMonthName()

QString QCalendarBackend::standaloneMonthName ( const QLocale locale,
int  month,
int  year,
QLocale::FormatType  format 
) const
virtual

Returns the standalone name of the specified month in the chosen locale, using the specified format to determine how complete the name is.

If year is Unspecified, return the standalone name for the month that usually has this number within a typical year. Calendars with a leap month that isn't always the last may need to take account of the year to map the month number to the particular year's month with that number.

See also
monthName(), QLocale::standaloneMonthName()

Reimplemented in QGregorianCalendar.

Definition at line 3016 of file qlocale.cpp.

Here is the call graph for this function:

◆ standaloneWeekDayName()

QString QCalendarBackend::standaloneWeekDayName ( const QLocale locale,
int  day,
QLocale::FormatType  format 
) const
virtual

Returns the standalone name of the specified day of the week in the chosen locale, using the specified format to determine how complete the name is.

The base implementation handles day values from 1 to 7 using the standalone day names CLDR provides, which are suitable for calendards that use the same (Hebrew-derived) week as the Gregorian calendar.

Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 need to reimplement this method to handle such extra week-day values. They can assume that day is a value returned by the same calendar's dayOfWeek().

See also
dayOfWeek(), weekDayName(), QLocale::standaloneDayName()

Definition at line 3082 of file qlocale.cpp.

◆ weekDayName()

QString QCalendarBackend::weekDayName ( const QLocale locale,
int  day,
QLocale::FormatType  format 
) const
virtual

Returns the name of the specified day of the week in the chosen locale, using the specified format to determine how complete the name is.

The base implementation handles day values from 1 to 7 using the day names CLDR provides, which are suitable for calendards that use the same (Hebrew-derived) week as the Gregorian calendar.

Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 need to reimplement this method to handle such extra week-day values. They can assume that day is a value returned by the same calendar's dayOfWeek().

See also
dayOfWeek(), standaloneWeekDayName(), QLocale::dayName()

Definition at line 3053 of file qlocale.cpp.

Friends And Related Function Documentation

◆ QCalendar

friend class QCalendar
friend

Definition at line 96 of file qcalendarbackend_p.h.

◆ QtPrivate::QCalendarRegistry

friend class QtPrivate::QCalendarRegistry
friend

Definition at line 97 of file qcalendarbackend_p.h.


The documentation for this class was generated from the following files: