QDate: fix QDebug operator<<() for dates with year > 9999
ISODate only supports years in the range 0-9999; instead of printing an empty string, use date.toString(Qt::TextDate) instead. This is mostly useful for debugging DateTime unittests. Change-Id: Id09951ce0a15452e28cb41a3b918c5ef05caab09 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
fa9244700e
commit
b490bd0265
@ -5625,7 +5625,11 @@ QDebug operator<<(QDebug dbg, QDate date)
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QDate(";
|
||||
if (date.isValid())
|
||||
dbg.nospace() << date.toString(Qt::ISODate);
|
||||
// QTBUG-91070, ISODate only supports years in the range 0-9999
|
||||
if (int y = date.year(); y > 0 && y <= 9999)
|
||||
dbg.nospace() << date.toString(Qt::ISODate);
|
||||
else
|
||||
dbg.nospace() << date.toString(Qt::TextDate);
|
||||
else
|
||||
dbg.nospace() << "Invalid";
|
||||
dbg.nospace() << ')';
|
||||
|
Loading…
Reference in New Issue
Block a user