6 #ifndef SWIFT_MISC_TIMESTAMPBASED_H
7 #define SWIFT_MISC_TIMESTAMPBASED_H
26 IndexUtcTimestamp = CPropertyIndexRef::GlobalIndexITimestampBased,
27 IndexUtcTimestampFormattedYmdhms,
28 IndexUtcTimestampFormattedYmdhmsz,
29 IndexUtcTimestampFormattedMdhms,
30 IndexUtcTimestampFormattedMdhmsz,
31 IndexUtcTimestampFormattedDhms,
32 IndexUtcTimestampFormattedHms,
33 IndexUtcTimestampFormattedHm,
38 QDateTime getUtcTimestamp()
const;
44 qint64
getTimeDifferenceMs(qint64 compareTime)
const {
return compareTime - this->getMSecsSinceEpoch(); }
49 return qAbs(compareTime - this->getMSecsSinceEpoch());
55 return this->getTimeDifferenceMs(QDateTime::currentMSecsSinceEpoch());
61 return compare.getMSecsSinceEpoch() - this->getMSecsSinceEpoch();
70 return qAbs(this->getTimeDifferenceMs(compare));
74 void setTimestampToNull();
77 void setMSecsSinceEpoch(qint64 mSecsSinceEpoch) { m_timestampMSecsSinceEpoch = mSecsSinceEpoch; }
80 void setByYearMonthDayHourMinute(
const QString &yyyyMMddhhmmss);
83 void setUtcTimestamp(
const QDateTime ×tamp);
89 bool isNewerThan(qint64 mSecsSinceEpoch)
const;
95 bool isOlderThan(qint64 mSecsSinceEpoch)
const;
98 bool isOlderThanNowMinusOffset(
int offsetMs)
const;
110 qint64 msecsToNow()
const;
113 void setCurrentUtcTime();
116 void addMsecs(qint64 ms);
119 QString getFormattedUtcTimestampHms()
const;
122 QString getFormattedUtcTimestampHmsz()
const;
125 QString getFormattedUtcTimestampHm()
const;
128 QString getFormattedUtcTimestampDhms()
const;
131 QString getFormattedUtcTimestampMdhms()
const;
134 QString getFormattedUtcTimestampMdhmsz()
const;
137 QString getFormattedUtcTimestampYmdhms()
const;
140 QString getFormattedUtcTimestampYmdhmsz()
const;
143 bool hasValidTimestamp()
const;
146 static bool isAnyTimestampIndex(
int index);
173 qint64 m_timestampMSecsSinceEpoch = -1;
183 IndexOffsetMs =
static_cast<int>(CPropertyIndexRef::GlobalIndexITimestampBased) +
184 ITimestampBased::IndexMSecsSinceEpoch + 1,
185 IndexAdjustedMsWithOffset,
196 bool hasNonZeroOffsetTime()
const;
199 void addMsecsToOffsetTime(qint64 msToAdd);
202 QString getTimeOffsetWithUnit()
const;
210 this->setMSecsSinceEpoch(adjustedTimeMs - this->getTimeOffsetMs());
216 return this->getAdjustedMSecsSinceEpoch() - compareTime;
220 QString getTimestampAndOffset(
bool formatted)
const;
223 QString getFormattedTimestampAndOffset(
bool includeRawTimestamp)
const;
229 bool isNewerThanAdjusted(qint64 mSecsSinceEpoch)
const;
235 bool isOlderThanAdjusted(qint64 mSecsSinceEpoch)
const;
259 qint64 m_timeOffsetMs = 0;
Non-owning reference to a CPropertyIndex with a subset of its features.
qint64 getMSecsSinceEpoch() const
Timestamp as ms value.
qint64 getTimeDifferenceMs(qint64 compareTime) const
Time difference in ms.
qint64 getAbsTimeDifferenceMs(const ITimestampBased &compare) const
Time difference in ms.
ColumnIndex
Properties by index.
qint64 getTimeDifferenceToNowMs() const
Time difference to now.
qint64 getTimeDifferenceMs(const ITimestampBased &compare) const
Time difference in ms.
qint64 getTimeDifferenceAbsMs(qint64 compareTime) const
Time difference in ms.
qint64 getAbsTimeDifferenceMs(qint64 compareTime) const
Time difference in ms.
void setMSecsSinceEpoch(qint64 mSecsSinceEpoch)
Timestamp as ms value.
qint64 getAdjustedMSecsSinceEpoch() const
Timestamp with offset added for interpolation.
ITimestampWithOffsetBased(const QDateTime ×tamp)
Constructor.
ITimestampWithOffsetBased()
Constructor.
void setAdjustedMSecsSinceEpoch(qint64 adjustedTimeMs)
Set timestamp with offset added for interpolation.
qint64 getTimeOffsetMs() const
Milliseconds to add to timestamp for interpolation.
qint64 getAdjustedTimeDifferenceMs(qint64 compareTime) const
Time difference in ms (this -> compare)
ITimestampWithOffsetBased(qint64 msSincePoch)
Constructor.
void setTimeOffsetMs(qint64 offset)
Milliseconds to add to timestamp for interpolation.
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.