path: root/src/corelib/tools/qdatetime.h
diff options
authorJohn Layt <>2013-08-13 14:17:08 +0200
committerThe Qt Project <>2013-09-13 22:06:26 +0200
commit92b0a7fa3ee874bc4a9a39da112896fa7e3a97e9 (patch)
tree180907eca0248aed0b3fe44c238a96c56978cd4a /src/corelib/tools/qdatetime.h
parent63a382a93073a96457a41118753ae88547023cac (diff)
QTime - Add public api for get/set msecs since start of day
Add new public api to get and set the number of msecs since the start of the day. Modify QDateTime to use the new msecs api. [ChangeLog][QtCore][QTime] Added new methods fromMSecsSinceStartOfDay() to create a new QTime from an msecs value, and msecsSinceStartOfDay() to return the QTime as the number of msecs since the start of the day. Change-Id: I285b725b883f1f5524fda87ca81bd64ed99fe6f4 Reviewed-by: Lars Knoll <> Reviewed-by: Mitch Curtis <>
Diffstat (limited to 'src/corelib/tools/qdatetime.h')
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 8b63c5a377..779aae5b5b 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -168,6 +168,9 @@ public:
bool operator>(const QTime &other) const { return mds > other.mds; }
bool operator>=(const QTime &other) const { return mds >= other.mds; }
+ static inline QTime fromMSecsSinceStartOfDay(int msecs) { QTime t; t.mds = msecs; return t; }
+ inline int msecsSinceStartOfDay() const { return mds == NullTime ? 0 : mds; }
static QTime currentTime();
static QTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);