Ref T129, utility function for timestamp based interface

This commit is contained in:
Klaus Basan
2017-09-30 20:11:15 +02:00
committed by Mathew Sutcliffe
parent ba8d0c1f64
commit bfa3908a99
2 changed files with 9 additions and 0 deletions

View File

@@ -126,6 +126,12 @@ namespace BlackMisc
return dt > 0 ? dt : dt * -1; return dt > 0 ? dt : dt * -1;
} }
qint64 ITimestampBased::msecsToNow() const
{
if (this->m_timestampMSecsSinceEpoch < 0) return QDateTime::currentMSecsSinceEpoch();
return QDateTime::currentMSecsSinceEpoch() - this->m_timestampMSecsSinceEpoch;
}
void ITimestampBased::setCurrentUtcTime() void ITimestampBased::setCurrentUtcTime()
{ {
this->m_timestampMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); this->m_timestampMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();

View File

@@ -80,6 +80,9 @@ namespace BlackMisc
//! Time difference //! Time difference
qint64 absMsecsTo(const ITimestampBased &otherTimestampObj) const; qint64 absMsecsTo(const ITimestampBased &otherTimestampObj) const;
//! Milliseconds to now
qint64 msecsToNow() const;
//! Set the current time as timestamp //! Set the current time as timestamp
void setCurrentUtcTime(); void setCurrentUtcTime();