diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-03-28 19:32:07 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-04-22 20:04:30 +0200 |
commit | b490bd0265491e8af0bcb1c08159a3a23ac4331e (patch) | |
tree | 36586badf3a2c7c488d2dddf37344cf0ef493cd8 /src/corelib/time/qdatetime.cpp | |
parent | fa9244700e016403b162932211023c65f4bb0d6b (diff) |
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>
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index b484196350..05031e22db 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -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() << ')'; |