mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-10-08 00:00:29 -04:00
Add some basic QDateTime rounding/truncation functions
This commit is contained in:
@@ -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 seconds)
|
||||
{
|
||||
dt.setSecsSinceEpoch (dt.addSecs (seconds - 1).toSecsSinceEpoch () / seconds * seconds);
|
||||
return dt;
|
||||
}
|
||||
|
||||
QDateTime qt_truncate_date_time_to (QDateTime dt, int seconds)
|
||||
{
|
||||
dt.setSecsSinceEpoch (dt.toSecsSinceEpoch () / seconds * seconds);
|
||||
return dt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user