summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-03-21 19:44:33 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-06 18:08:56 +0200
commit94a757665885443eaa199649492855aa75d4c5ec (patch)
tree902125f6b4d7b53ba2f3181344230a9a9151c971 /src/corelib
parent0771075f664e1a49e586357bc86c915042e440eb (diff)
QDateTime - Change debug output to ISO Format
Change the debug format from Qt::TextDate to a more detailed ISO style format including better time spec output. [ChangeLog][QtCore][QDateTime] The debug datastream is now an ISO-like format instead of Qt::TextDate Change-Id: Iddbb8199c3bfbf7bca845482617e7a85da43259d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qdatetime.cpp21
-rw-r--r--src/corelib/tools/qdatetime.h4
2 files changed, 22 insertions, 3 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 3e5600b484..ab5a516e8a 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -4391,19 +4391,34 @@ void QDateTimePrivate::getUTC(QDate &outDate, QTime &outTime) const
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
QDebug operator<<(QDebug dbg, const QDate &date)
{
- dbg.nospace() << "QDate(" << date.toString() << ')';
+ dbg.nospace() << "QDate(" << date.toString(QStringLiteral("yyyy-MM-dd")) << ')';
return dbg.space();
}
QDebug operator<<(QDebug dbg, const QTime &time)
{
- dbg.nospace() << "QTime(" << time.toString() << ')';
+ dbg.nospace() << "QTime(" << time.toString(QStringLiteral("HH:mm:ss.zzz")) << ')';
return dbg.space();
}
QDebug operator<<(QDebug dbg, const QDateTime &date)
{
- dbg.nospace() << "QDateTime(" << date.toString() << ')';
+ QString spec;
+ switch (date.d->spec) {
+ case QDateTimePrivate::UTC :
+ spec = QStringLiteral(" Qt::UTC");
+ break;
+ case QDateTimePrivate::OffsetFromUTC :
+ spec = QString::fromUtf8(" Qt::OffsetFromUTC %1s").arg(date.offsetFromUtc());
+ break;
+ case QDateTimePrivate::LocalDST :
+ case QDateTimePrivate::LocalStandard :
+ case QDateTimePrivate::LocalUnknown :
+ default :
+ spec = QStringLiteral(" Qt::LocalTime");
+ }
+ QString output = date.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")) + spec;
+ dbg.nospace() << "QDateTime(" << output << ')';
return dbg.space();
}
#endif
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 25f5b74eb2..8b63c5a377 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -293,6 +293,10 @@ private:
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
#endif
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
+ friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
+#endif
};
Q_DECLARE_SHARED(QDateTime)