summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale.h
diff options
context:
space:
mode:
authorSoroush Rabiei <soroush@ametisco.ir>2017-01-14 20:23:31 +0330
committerEdward Welbourne <edward.welbourne@qt.io>2019-08-20 13:41:21 +0200
commitaa8393c94fea01a4806b204fd3aa343a4e90666b (patch)
tree071cf0bd8934b094d4e0208a25c11f439acb8173 /src/corelib/text/qlocale.h
parent8f083bade0ba33d4be8a2d3ed1b5ce005aab6d8d (diff)
Add support for calendars beside Gregorian
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>
Diffstat (limited to 'src/corelib/text/qlocale.h')
-rw-r--r--src/corelib/text/qlocale.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h
index 09de830ca3..87966b266b 100644
--- a/src/corelib/text/qlocale.h
+++ b/src/corelib/text/qlocale.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
-
+class QCalendar;
class QDataStream;
class QDate;
class QDateTime;
@@ -1013,6 +1013,14 @@ public:
QString toString(const QDate &date, FormatType format = LongFormat) const;
QString toString(const QTime &time, FormatType format = LongFormat) const;
QString toString(const QDateTime &dateTime, FormatType format = LongFormat) const;
+ /* Removing default value for `format' is done intentionally,
+ * after all tests we will remove non-calendar-aware version of these functions,
+ * and add a default value for both calendar instance, and format
+ */
+ QString toString(const QDate &date, QStringView formatStr, QCalendar cal) const;
+ QString toString(const QDate &date, FormatType format, QCalendar cal) const;
+ QString toString(const QDateTime &dateTime, FormatType format, QCalendar cal) const;
+ QString toString(const QDateTime &dateTime, QStringView formatStr, QCalendar cal) const;
QString dateFormat(FormatType format = LongFormat) const;
QString timeFormat(FormatType format = LongFormat) const;
@@ -1024,6 +1032,13 @@ public:
QDate toDate(const QString &string, const QString &format) const;
QTime toTime(const QString &string, const QString &format) const;
QDateTime toDateTime(const QString &string, const QString &format) const;
+ // Calendar-aware API
+ QDate toDate(const QString &string, FormatType format, QCalendar cal) const;
+ QTime toTime(const QString &string, FormatType format, QCalendar cal) const;
+ QDateTime toDateTime(const QString &string, FormatType format, QCalendar cal) const;
+ QDate toDate(const QString &string, const QString &format, QCalendar cal) const;
+ QTime toTime(const QString &string, const QString &format, QCalendar cal) const;
+ QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const;
#endif
// ### Qt 5: We need to return QString from these function since
@@ -1108,6 +1123,8 @@ private:
QLocale(QLocalePrivate &dd);
friend class QLocalePrivate;
friend class QSystemLocale;
+ friend class QCalendarBackend;
+ friend class QGregorianCalendar;
friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) noexcept;
QSharedDataPointer<QLocalePrivate> d;