From 92b0a7fa3ee874bc4a9a39da112896fa7e3a97e9 Mon Sep 17 00:00:00 2001 From: John Layt Date: Tue, 13 Aug 2013 14:17:08 +0200 Subject: 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 --- src/corelib/tools/qdatetime.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/tools/qdatetime.h') 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(); #ifndef QT_NO_DATESTRING static QTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); -- cgit v1.2.3