summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-04-07 09:17:07 (GMT)
committerTobias Markmann <tm@ayena.de>2017-04-07 10:42:24 (GMT)
commited2226782ac15345aeb8e615b41d30e5aab67b51 (patch)
treea519ef4b314570fb134b969bb5fcff0e1f2be6e9 /Swift/QtUI/QtUtilities.cpp
parent7d2e5e200d8449a4492c6fafa4811197e6fbe40b (diff)
downloadswift-ed2226782ac15345aeb8e615b41d30e5aab67b51.zip
swift-ed2226782ac15345aeb8e615b41d30e5aab67b51.tar.bz2
Make day change chat system message DST aware
Moved the code for day change message handling from Swift/Controllers to Swift/QtUI. Use QDateTime in local time time spec, which allows DST aware calculation of the duration to the next midnight. Added Swift Qt UI unit tests, which are build when Qt has been successfully detected. Test-Information: Added unit tests for duration to next midnight calculation. Set clock shortly before midnight and verified that a single day change message is added to the chat log at midnight. Tested on macOS 10.12.4 with Qt 5.4.2. Change-Id: I34d69eaa3272981fd220a7963a0417f73ff78e68
Diffstat (limited to 'Swift/QtUI/QtUtilities.cpp')
-rw-r--r--Swift/QtUI/QtUtilities.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/Swift/QtUI/QtUtilities.cpp b/Swift/QtUI/QtUtilities.cpp
index 401af17..6eb0b04 100644
--- a/Swift/QtUI/QtUtilities.cpp
+++ b/Swift/QtUI/QtUtilities.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include "QtUtilities.h"
+#include <Swift/QtUI/QtUtilities.h>
#include <QtGui>
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
@@ -14,8 +14,9 @@
#endif
#include <QTextDocument>
#include <QWidget>
+#include <QDateTime>
-#include "Swift/Controllers/ApplicationInfo.h"
+#include <Swift/Controllers/ApplicationInfo.h>
namespace QtUtilities {
@@ -42,4 +43,12 @@ QString htmlEscape(const QString& s) {
#endif
}
+long long secondsToNextMidnight(const QDateTime& currentTime) {
+ auto secondsToMidnight = 0ll;
+ auto nextMidnight = currentTime.addDays(1);
+ nextMidnight.setTime(QTime(0,0));
+ secondsToMidnight = currentTime.secsTo(nextMidnight);
+ return secondsToMidnight;
+}
+
}