summaryrefslogtreecommitdiff
path: root/qt_helpers.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-09-28 23:28:13 +0200
committerChristoph Berg <myon@debian.org>2020-09-28 23:28:13 +0200
commit7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (patch)
treeda509a2cf3667b6f9855ea811f4a1f95d9e6f5ef /qt_helpers.cpp
parent28f34ff4908a90b1a7323b2988c33cdb1779fa06 (diff)
New upstream version 2.3.0~rc1+repackupstream/2.3.0_rc1+repack
Diffstat (limited to 'qt_helpers.cpp')
-rw-r--r--qt_helpers.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/qt_helpers.cpp b/qt_helpers.cpp
index 62def121..dd474e19 100644
--- a/qt_helpers.cpp
+++ b/qt_helpers.cpp
@@ -5,6 +5,7 @@
#include <QWidget>
#include <QStyle>
#include <QVariant>
+#include <QDateTime>
QString font_as_stylesheet (QFont const& font)
{
@@ -35,3 +36,15 @@ void update_dynamic_property (QWidget * widget, char const * property, QVariant
widget->style ()->polish (widget);
widget->update ();
}
+
+QDateTime qt_round_date_time_to (QDateTime dt, int milliseconds)
+{
+ dt.setMSecsSinceEpoch (dt.addMSecs (milliseconds / 2).toMSecsSinceEpoch () / milliseconds * milliseconds);
+ return dt;
+}
+
+QDateTime qt_truncate_date_time_to (QDateTime dt, int milliseconds)
+{
+ dt.setMSecsSinceEpoch (dt.toMSecsSinceEpoch () / milliseconds * milliseconds);
+ return dt;
+}