2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-04 18:17:42 +02:00
|
|
|
#include "Library/Chrono.hpp"
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-08-18 20:37:33 +02:00
|
|
|
class Date;
|
|
|
|
class Time;
|
2016-02-21 06:40:06 +01:00
|
|
|
class Timer;
|
2021-08-18 20:37:33 +02:00
|
|
|
class Datetime;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class Timestamp
|
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
friend class Timer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp()
|
|
|
|
: m_Timestamp(0)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
explicit Timestamp(int64_t t)
|
2016-02-21 06:40:06 +01:00
|
|
|
: m_Timestamp(t)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
explicit Timestamp(const SLongInt & t);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Timestamp(const Timestamp & o) = default;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
~Timestamp() = default;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & operator = (const Timestamp o)
|
|
|
|
{
|
|
|
|
m_Timestamp = o.m_Timestamp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
Timestamp operator + (const Timestamp & o) const
|
|
|
|
{
|
|
|
|
return Timestamp(m_Timestamp + o.m_Timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
Timestamp operator - (const Timestamp & o) const
|
|
|
|
{
|
|
|
|
return Timestamp(m_Timestamp - o.m_Timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
Timestamp operator * (const Timestamp & o) const
|
|
|
|
{
|
|
|
|
return Timestamp(m_Timestamp * o.m_Timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
Timestamp operator / (const Timestamp & o) const
|
|
|
|
{
|
|
|
|
return Timestamp(m_Timestamp / o.m_Timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(const Timestamp & b) const;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String ToString() const;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
void SetNow();
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-27 10:57:10 +01:00
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int64_t GetNum() const
|
2016-02-27 10:57:10 +01:00
|
|
|
{
|
|
|
|
return m_Timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-21 06:40:06 +01:00
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SLongInt GetMicroseconds() const;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMicroseconds(const SLongInt & amount);
|
2016-02-21 06:40:06 +01:00
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMicroseconds(const SLongInt & amount);
|
|
|
|
Timestamp & SubMicroseconds(const SLongInt & amount);
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetMicrosecondsRaw() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMicrosecondsRaw(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = amount;
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMicrosecondsRaw(SQInteger amount) { m_Timestamp += amount; return *this; }
|
|
|
|
Timestamp & SubMicrosecondsRaw(SQInteger amount) { m_Timestamp -= amount; return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SLongInt GetMilliseconds() const;
|
2016-02-21 06:40:06 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMilliseconds(const SLongInt & amount);
|
2016-02-21 06:40:06 +01:00
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMilliseconds(const SLongInt & amount);
|
|
|
|
Timestamp & SubMilliseconds(const SLongInt & amount);
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetMillisecondsRaw() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 1000L);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMillisecondsRaw(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(int64_t(amount) * 1000L);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMillisecondsRaw(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000L); return *this; }
|
|
|
|
Timestamp & SubMillisecondsRaw(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000L); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQFloat GetSecondsF() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return static_cast< SQFloat >(static_cast< int64_t >(m_Timestamp / 1000000LL));
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetSecondsF(SQFloat amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 1000000L);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddSecondsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 1000000L); return *this; }
|
|
|
|
Timestamp & SubSecondsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 1000000L); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetSecondsI() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 1000000L);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetSecondsI(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(int64_t(amount) * 1000000L);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddSecondsI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000000L); return *this; }
|
|
|
|
Timestamp & SubSecondsI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000000L); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQFloat GetMinutesF() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return SQFloat(m_Timestamp / 60000000.0);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMinutesF(SQFloat amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 60000000L);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMinutesF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 60000000L); return *this; }
|
|
|
|
Timestamp & SubMinutesF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 60000000L); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetMinutesI() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 60000000L);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMinutesI(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(int64_t(amount) * 60000000L);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddMinutesI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 60000000L); return *this; }
|
|
|
|
Timestamp & SubMinutesI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 60000000L); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQFloat GetHoursF() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return SQFloat(m_Timestamp / 3600000000.0);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetHoursF(SQFloat amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddHoursF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
|
|
|
Timestamp & SubHoursF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetHoursI() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 3600000000LL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetHoursI(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddHoursI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
|
|
|
Timestamp & SubHoursI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQFloat GetDaysF() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return SQFloat(m_Timestamp / 86400000000.0);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetDaysF(SQFloat amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddDaysF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
|
|
|
Timestamp & SubDaysF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetDaysI() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 86400000000LL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetDaysI(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddDaysI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
|
|
|
Timestamp & SubDaysI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQFloat GetYearsF() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return SQFloat(m_Timestamp / 31557600000000.0);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetYearsF(SQFloat amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddYearsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
|
|
|
Timestamp & SubYearsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQInteger GetYearsI() const
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
|
|
|
return SQInteger(m_Timestamp / 31557600000000LL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetYearsI(SQInteger amount)
|
2016-02-21 06:40:06 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
2016-02-21 06:40:06 +01:00
|
|
|
}
|
|
|
|
|
2021-08-18 20:37:33 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddYearsI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
|
|
|
Timestamp & SubYearsI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
SQMOD_NODISCARD Time GetTime() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SetTime(const Time & t);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddTime(const Time & t);
|
|
|
|
Timestamp & SubTime(const Time & t);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
SQMOD_NODISCARD Date GetDate() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SetDate(const Date & d);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddDate(const Date & d);
|
|
|
|
Timestamp & SubDate(const Date & d);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
SQMOD_NODISCARD Datetime GetDatetime() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SetDatetime(const Datetime & dt);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Timestamp & AddDatetime(const Datetime & dt);
|
|
|
|
Timestamp & SubDatetime(const Datetime & dt);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
std::time_t ToTimeT() const;
|
|
|
|
|
2016-02-21 06:40:06 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int64_t m_Timestamp;
|
2016-02-21 06:40:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|