Deprecate QLocale::toTime() variants taking a calendar
The calendar is ignored, so adding these methods was a mistake. [ChangeLog][QtCore][QLocale] Deprecated toTime() variants taking a calendar. The calendar is ignored in time parsing. Change-Id: I79fa994ce88f13fdb931163b447eb1a9ad655c09 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
d6ba2ae441
commit
6c4e0f2d2d
@ -2353,14 +2353,19 @@ QTime QLocale::toTime(const QString &string, FormatType format) const
|
|||||||
return toTime(string, timeFormat(format));
|
return toTime(string, timeFormat(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
/*!
|
/*!
|
||||||
\since 5.14
|
\since 5.14
|
||||||
\overload
|
\overload
|
||||||
|
\deprecated
|
||||||
*/
|
*/
|
||||||
QTime QLocale::toTime(const QString &string, FormatType format, QCalendar cal) const
|
QTime QLocale::toTime(const QString &string, FormatType format, QCalendar cal) const
|
||||||
{
|
{
|
||||||
|
QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
|
||||||
return toTime(string, timeFormat(format), cal);
|
return toTime(string, timeFormat(format), cal);
|
||||||
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.4
|
\since 4.4
|
||||||
@ -2425,12 +2430,24 @@ QDateTime QLocale::toDateTime(const QString &string, FormatType format, QCalenda
|
|||||||
*/
|
*/
|
||||||
QTime QLocale::toTime(const QString &string, const QString &format) const
|
QTime QLocale::toTime(const QString &string, const QString &format) const
|
||||||
{
|
{
|
||||||
return toTime(string, format, QCalendar());
|
QTime time;
|
||||||
|
#if QT_CONFIG(datetimeparser)
|
||||||
|
QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar());
|
||||||
|
dt.setDefaultLocale(*this);
|
||||||
|
if (dt.parseFormat(format))
|
||||||
|
dt.fromString(string, nullptr, &time);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(string);
|
||||||
|
Q_UNUSED(format);
|
||||||
|
#endif
|
||||||
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
/*!
|
/*!
|
||||||
\since 5.14
|
\since 5.14
|
||||||
\overload
|
\overload
|
||||||
|
\deprecated
|
||||||
*/
|
*/
|
||||||
QTime QLocale::toTime(const QString &string, const QString &format, QCalendar cal) const
|
QTime QLocale::toTime(const QString &string, const QString &format, QCalendar cal) const
|
||||||
{
|
{
|
||||||
@ -2447,6 +2464,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca
|
|||||||
#endif
|
#endif
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.4
|
\since 4.4
|
||||||
|
@ -1037,11 +1037,15 @@ public:
|
|||||||
QDateTime toDateTime(const QString &string, const QString &format) const;
|
QDateTime toDateTime(const QString &string, const QString &format) const;
|
||||||
// Calendar-aware API
|
// Calendar-aware API
|
||||||
QDate toDate(const QString &string, FormatType format, QCalendar cal) const;
|
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;
|
QDateTime toDateTime(const QString &string, FormatType format, QCalendar cal) const;
|
||||||
QDate toDate(const QString &string, const QString &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;
|
QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const;
|
||||||
|
# if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_DEPRECATED_X("Calendar is ignored when parsing times")
|
||||||
|
QTime toTime(const QString &string, FormatType format, QCalendar cal) const;
|
||||||
|
QT_DEPRECATED_X("Calendar is ignored when parsing times")
|
||||||
|
QTime toTime(const QString &string, const QString &format, QCalendar cal) const;
|
||||||
|
# endif // 5.15
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ### Qt 6: We need to return QString from these function since
|
// ### Qt 6: We need to return QString from these function since
|
||||||
|
Loading…
x
Reference in New Issue
Block a user