summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qcalendar.h
Commit message (Collapse)AuthorAgeFilesLines
* QCalendar: Delete registered calendar backends on program exitIevgenii Meshcheriakov2021-08-061-2/+5
| | | | | | | | | Add code to check if the calendar registry is destroyed to all QCalendar methods that dereference QCalendarBackend pointer. Pick-to: 6.2 Change-Id: I9b562355e2e0579396b52968f6065c6927cc9ca8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendar: Thread-safe calendar backend registrationIevgenii Meshcheriakov2021-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All calendar backend accounting was moved into QCalendarRegistry class (renamed from Registry). Calendar backends are no longer registered inside constructors, because in multithreaded environment this may lead to incompletely initialized instances becoming visible via QCalendar API in multithreaded environment. All system backends are registered by QCalendarRegistry itself when they are needed. New method QCalendarBackend::registerCustomBackend() is provided to register any 3rd-party calendar backends. Registration by names was also simplified. The list of names is now passed to QCalendarBackend::registerCustomBackend(). The checks are provided to ensure that all system backends have non-conflicting names. Name conflicts for custom backends are resolved in favor of earlier registered backends, as it is already the case in the existing code. The documentation was updated to reflect that. Method QCalendarBackend::names() was added to query the list of names associated with a backend after it is registered. Calendar backend deregistration was completely removed because it is not possible to perform it safely without reference counting. Fixes: QTBUG-93004 Pick-to: 6.2 Change-Id: I0ab1eccc02fdd1e1c66b5e5dd076c93de32d5a49 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendar: Make SystemId constructors with one argument explicitIevgenii Meshcheriakov2021-07-271-2/+3
| | | | | | | | This avoids unwanted type conversions. Pick-to: 6.2 Change-Id: Ie57e80da615c6bc162224fa3816fc21a47ab4b00 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendarBackend: Use QAnyStringView to create backends by nameIevgenii Meshcheriakov2021-07-271-0/+2
| | | | | | | | | | | | | | Combine two implementations of QCalendarBackend::byName() accepting QStringView and QLatin1String arguments into one accepting QAnyStringView to reduce code duplication. Add a note to QCalendar constructors accepting strings to do the same for Qt 7. Change-Id: Idfc3b9c61e22712543c723bd94fcd788da52780a Pick-to: 6.2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make QCalendarBackend's ID an opaque typeEdward Welbourne2021-07-191-2/+14
| | | | | | | | | | As Giuseppe pointed out in API change review, an opaque type should be used. Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I862a6f52d284317e1243fd91f45bb0af130d154a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Provide calendar backends with a unique IDEdward Welbourne2021-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | Registration by ID allows for detection of duplicate instantiation of built-in back-ends, which can be detected and flagged by setting the ID to ~size_t(0) instead of the enum value for which it sought to be registered. A new method, calendarId(), is provided to access this; while the old calendarSystem() becomes non-virtual, as it can be inferred (when registration was successful) from the ID. Make registration by name or alias conditional on successful registration by ID. Previously, failed registration by name precluded registration by ID, which now becomes the authoritative registration. This incidentally makes it possible to add a QCalendar constructor taking the unique ID of a backend, for use in conjunction with custom calendar implementations. Change-Id: Ib22925a8ac3ef9439a09ec3855f6231cf9b91c21 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass QDate and QTime as value classesEdward Welbourne2020-02-271-2/+2
| | | | | | | | | It's what they are, so const refs are needless burden. In the process, consolidate two of the affected methods (one of which just adds another argument to the other's signature) into one. Change-Id: I80de35ffe078a652d1999889dede0b10302abaa9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QCalendar::isValid(): make it constEdward Welbourne2019-09-261-1/+1
| | | | | | | | Spotted in API change review, thanks to Albert Astals Cid. Also added documentation of this method. Change-Id: I2ef2c526a98b571a3cb3bb5f93d1952b1b0d63a9 Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
* Rename calendar methods from m{in,ax} to m{in,ax}imumEdward Welbourne2019-09-041-3/+3
| | | | | | | | | 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>
* Fix some qdoc warnings in 5.14Friedemann Kleint2019-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark QCalendarBackend as internal since it is in a private header and fix some issues in the QCalendar related classes. src/corelib/time/qcalendar.cpp:201: (qdoc) warning: clang found diagnostics parsing \fn int QCalendarBackend::daysInMonth(int month, int year) const error: incomplete type 'QCalendarBackend' named in nested name specifier (repeats) src/corelib/time/qdatetime.cpp:1426: (qdoc) warning: Unknown command '\override' (repeats) src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'Last' in QCalendar::System src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'User' in QCalendar::System src/corelib/time/qcalendar.cpp:744: (qdoc) warning: Undocumented parameter 'year' in QCalendar::isLeapYear() src/corelib/time/qcalendar.cpp:923: (qdoc) warning: Can't link to 'dateTimeString()' (repeats) src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'year' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'month' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'day' in QCalendar::partsFromDate() src/corelib/time/qdatetime.cpp:1425: (qdoc) warning: Undocumented parameter 'nmonths' in QDate::addMonths() src/corelib/time/qdatetime.cpp:1467: (qdoc) warning: Undocumented parameter 'nyears' in QDate::addYears() src/corelib/statemachine/qstatemachine.cpp:2522: (qdoc) warning: Undocumented enum item 'StateMachineChildModeSetToParallelError' in QStateMachine::Error src/corelib/kernel/qtimer.cpp:602: (qdoc) warning: Undocumented parameter 'connectionType' in QTimer::callOnTimeout() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'name' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'id' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'registerCalendar()' src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'fromName()' src/corelib/time/qcalendar.cpp:178: (qdoc) warning: Can't link to 'QCalendar::fromEnum()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Undocumented parameter 'jd' in QCalendarBackend::dayOfWeek() src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'weekDayName()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'standaloneWeekDayName()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'isLeapYear()' src/corelib/time/qcalendar.cpp:295: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLuniSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLunar()' src/corelib/time/qcalendar.cpp:340: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:357: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:544: (qdoc) warning: Can't link to 'fromName()' Change-Id: Ia2fabefb917f8e4cfa361044d9b754717276f4aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add support for the Islamic Civil calendarSoroush Rabiei2019-08-221-3/+11
| | | | | | | | | | | | | | | | This has its own locale data, extracted from CLDR. This data may potentially be shared with other variants on the Islamic calendar, so is handled by a separate base-class, QHijriCalendar, on which such variants may base their implementations. [ChangeLog][QtCore][QCalendar] Added support for the Islamic Civil calendar, controlled by feature islamiccivilcalendar, with locale data that can be shared with other implementations, controlled by feature hijricalendar. Fixes: QTBUG-56675 Change-Id: Idf32d3da7034baa8ec5e66ef847e59a8a2f31cbd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add support for the Jalali (Solar Hijri or Persian) calendarSoroush Rabiei2019-08-211-1/+7
| | | | | | | | | | | | This has its own locale data, extracted from CLDR. [ChangeLog][QtCore][QCalendar] Added support for the Jalali (Persian or Solar Hijri) calendar, controlled by feature jalalicalendar. Fixes: QTBUG-58404 Change-Id: Id5c56a10db05a4fd612aafc01615273db81ec743 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add support for Julian and Milankovic calendarsSoroush Rabiei2019-08-211-2/+7
| | | | | | | | | | | | | These share their locale data with the Gregorian calendar, making them virtually free to add. Still leave them out of the boot-strap build, though. [ChangeLog][QtCore][QCalendar] Added support for Julian and Milankovic calendars. These are enabled by default, except in bootstrap builds. Change-Id: I585045ed9e78c1e959957f6772b3e144093b701c Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add support for calendars beside GregorianSoroush Rabiei2019-08-201-0/+174
Add QCalendarBackend as a base class for calendar implementations and QCalendar as a facade via which to access it. QDate's implicit implementation of the Gregorian calendar becomes QGregorianCalendar and QDate methods now support choice of calendar. Convert QLocale's CLDR data for month names to a locale-data component of each supported calendar and relevant QLocale methods now support choice of calendar. Adapt Python scripts for locale data generation to extract month name data from CLDR (keeping on version v35.1) into the new calendar-locale files. The locale data for the Gregorian calendar is held in a Roman calendar base, for sharing with other calendars. Add tests for basic uses of the new API. [ChangeLog][QtCore][QCalendar] Added QCalendar to support diverse calendars, supported by implementing QCalendarBackend. [ChangeLog][QtCore][QDate] Allow choice of calendar in various operations, with Gregorian remaining the default. Done-with: Lars Knoll <lars.knoll@qt.io> Done-with: Edward Welbourne <edward.welbourne@qt.io> Fixes: QTBUG-17110 Fixes: QTBUG-950 Change-Id: I9d6278f394269a183aee8156e990cec4d5198ab8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>