diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2024-01-17 16:30:03 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-01-22 14:18:09 +0100 |
commit | cde7d5d3ff56fdf219771c65bf93f3f08757f154 (patch) | |
tree | e57f3a91a9af96b9544250adb0756ec1d3afcb13 /src/corelib/text/qlocale.h | |
parent | e957ed97e0a7f6974db7d9f7ea52d94785464880 (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.h')
-rw-r--r-- | src/corelib/text/qlocale.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index bc04ae5cdc..3027067363 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -35,9 +35,9 @@ class Q_CORE_EXPORT QLocale friend class QTextStream; friend class QTextStreamPrivate; - static constexpr int FirstTwoDigitYear = 1900; // sync with QDate - public: + static constexpr int DefaultTwoDigitBaseYear = 1900; + // see qlocale_data_p.h for more info on generated data // GENERATED PART STARTS HERE enum Language : ushort { @@ -1030,22 +1030,22 @@ public: QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const; # endif QDate toDate(const QString &string, FormatType = LongFormat, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDate toDate(const QString &string, const QString &format, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDateTime toDateTime(const QString &string, FormatType format = LongFormat, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDateTime toDateTime(const QString &string, const QString &format, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; // Calendar-aware API QDate toDate(const QString &string, FormatType format, QCalendar cal, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDate toDate(const QString &string, const QString &format, QCalendar cal, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDateTime toDateTime(const QString &string, FormatType format, QCalendar cal, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal, - int baseYear = FirstTwoDigitYear) const; + int baseYear = DefaultTwoDigitBaseYear) const; #endif QString decimalPoint() const; |