summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-01-17 16:30:03 +0100
committerIvan Solovev <ivan.solovev@qt.io>2024-01-22 14:18:09 +0100
commitcde7d5d3ff56fdf219771c65bf93f3f08757f154 (patch)
treee57f3a91a9af96b9544250adb0756ec1d3afcb13 /src/corelib/text/qlocale.cpp
parente957ed97e0a7f6974db7d9f7ea52d94785464880 (diff)
Make public QLocale's constant for the two-digit-year base
The private QLocale::FirstTwoDigitYear constant, which is used as a default value for the parameters in some methods, causes troubles for Qt for Python Team, because they need to use the default values in the binding code. It also potentially create some inconveniences for the users who want to write functions wrapping these methods. The name is also confusing, because, when read out of context, it implies that there might be SecondTwoDigitYear, etc... Rename QLocale::FirstTwoDigitYear to QLocale::DefaultTwoDigitBaseYear and make it public. Now when the constant is public, we can use it in QDate, instead of introducing another constant, so do that. The qdatetime.h header already includes qlocale.h via qcalendar.h, but, rather than relying on this transitive include, add it explicitly. As pointed out by Thiago [1], the static constexpr members of exported classes need out-of-line definitions, so add such definition to qlocale.cpp. Amends 41f84f3ddb780ec751e3fc706dd242fc4a99de7a Found in 6.7 API review. [1]: https://lists.qt-project.org/pipermail/development/2024-January/044888.html Pick-to: 6.7 Change-Id: Ib3c6f1d5b181968bf311fd0435173e025a369865 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r--src/corelib/text/qlocale.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 65af3a012d..7e08903055 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -54,6 +54,8 @@ QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking
QT_BEGIN_NAMESPACE
+constexpr int QLocale::DefaultTwoDigitBaseYear;
+
QT_IMPL_METATYPE_EXTERN_TAGGED(QList<Qt::DayOfWeek>, QList_Qt__DayOfWeek)
#ifndef QT_NO_SYSTEMLOCALE
QT_IMPL_METATYPE_EXTERN_TAGGED(QSystemLocale::CurrencyToStringArgument,
@@ -1001,6 +1003,21 @@ QLocale::QLocale(QLocalePrivate &dd)
: d(&dd)
{}
+/*!
+ \variable QLocale::DefaultTwoDigitBaseYear
+ \since 6.7
+
+ \brief The default start year of the century within which a format taking
+ a two-digit year will select. The value of the constant is \c {1900}.
+
+ Some locales use, particularly for ShortFormat, only the last two digits of
+ the year. Proir to 6.7 the year 1900 was always used as a base year for
+ such cases. Now various QLocale and QDate functions have the overloads that
+ allow callers to specify the base year, and this constant is used as its
+ default value.
+
+ \sa toDate(), toDateTime(), QDate::fromString(), QDateTime::fromString()
+*/
/*!
\since 6.3