3 #if TTK_QT_VERSION_CHECK(5,10,0)
4 # include <QRandomGenerator>
9 #if !TTK_QT_VERSION_CHECK(5,10,0)
10 qsrand(QDateTime::currentMSecsSinceEpoch());
16 #if TTK_QT_VERSION_CHECK(5,10,0)
17 return QRandomGenerator::global()->bounded(value);
19 return qrand() % value;
41 fromValue(day, hour,
min, sec, msec);
67 const QTime &qtime = QTime::fromString(time, format);
68 t.
fromValue(0, qtime.hour(), qtime.minute(), qtime.second(), qtime.msec());
79 return QTime(m_hour, m_minute, m_second, m_msecond).toString(format);
84 if(day < 0 || hour < 0 || hour > 24 || min < 0 || min > 60 || sec < 0 || sec > 60 || msec < 0 || msec > 1000)
138 return QString::number(min).rightJustified(2,
'0') +
":" + QString::number(t.
second()).rightJustified(2,
'0');
156 fromValue(toValue() + other.toValue());
162 fromValue(toValue() + other);
168 fromValue(toValue() - other.toValue());
174 fromValue(toValue() - other);
180 fromValue(toValue() * other);
186 fromValue(toValue() / other);
192 return TTKTime(toValue() + other.toValue());
197 return TTKTime(toValue() + other);
202 return TTKTime(toValue() - other.toValue());
207 return TTKTime(toValue() - other);
212 return TTKTime(toValue() * other);
217 return TTKTime(toValue() / other);
222 return toValue() == other.toValue();
227 return toValue() != other.toValue();
242 m_hour = other.m_hour;
243 m_minute = other.m_minute;
244 m_second = other.m_second;
245 m_msecond = other.m_msecond;
251 return QDateTime::currentMSecsSinceEpoch();
256 return QString::number(QDateTime::fromString(time, format).toMSecsSinceEpoch());
261 return QDateTime::fromMSecsSinceEpoch(time).toString(format);
TTKTime & operator*=(const int other) noexcept
int minute() const noexcept
TTKTime operator+(const TTKTime &other) noexcept
TTKTime & operator/=(const int other) noexcept
static qint64 currentTimestamp() noexcept
TTKTime & operator-=(const TTKTime &other) noexcept
void fromValue(int day, int hour, int min, int sec, int msec=0) noexcept
TTK_MODULE_EXPORT void initRandom()
bool operator==(const TTKTime &other) const noexcept
void copyToThis(const TTKTime &other) noexcept
static TTKTime fromString(const QString &time, const QString &format) noexcept
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
TTKTime operator*(const int other) noexcept
int hour() const noexcept
TTKTime & operator+=(const TTKTime &other) noexcept
TTKTime & operator=(const TTKTime &other) noexcept
int second() const noexcept
bool isNull() const noexcept
The class of the ttk time object.
TTKTime operator-(const TTKTime &other) noexcept
bool isValid() const noexcept
void initialize() noexcept
TTKTime operator/(const int other) noexcept
static QString toString(qint64 time, const QString &format) noexcept
static QString format(const QString &time, const QString &format)
bool operator!=(const TTKTime &other) const noexcept
constexpr const _Tp & min(const _Tp &a, const _Tp &b)
static qint64 formatDuration(const QString &time) noexcept
qint64 toValue() const noexcept