mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-24 11:40:31 -05:00
Add some basic QDateTime rounding/truncation functions
This commit is contained in:
parent
6cb72a5f3e
commit
08d20e4366
@ -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;
|
||||
}
|
||||
|
@ -69,6 +69,12 @@ QString font_as_stylesheet (QFont const&);
|
||||
// conditional style sheet updates
|
||||
void update_dynamic_property (QWidget *, char const * property, QVariant const& value);
|
||||
|
||||
// round a QDateTime instance to an interval
|
||||
QDateTime qt_round_date_time_to (QDateTime dt, int seconds);
|
||||
|
||||
// truncate a QDateTime to an interval
|
||||
QDateTime qt_truncate_date_time_to (QDateTime dt, int seconds);
|
||||
|
||||
template <class T>
|
||||
class VPtr
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user