2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-04 18:17:42 +02:00
|
|
|
#include "Library/Chrono.hpp"
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-06-04 18:17:42 +02:00
|
|
|
* Helper class used to represent a certain date and time.
|
2016-03-25 13:28:07 +01:00
|
|
|
*/
|
2016-06-04 18:17:42 +02:00
|
|
|
class Datetime
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static SQChar Delimiter;
|
|
|
|
static SQChar DateDelim;
|
|
|
|
static SQChar TimeDelim;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
uint16_t m_Year{}; // Year
|
|
|
|
uint8_t m_Month{}; // Month
|
|
|
|
uint8_t m_Day{}; // Day
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
uint8_t m_Hour{}; // Hour
|
|
|
|
uint8_t m_Minute{}; // Minute
|
|
|
|
uint8_t m_Second{}; // Second
|
|
|
|
uint16_t m_Millisecond{}; // Millisecond
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQChar m_Delimiter; // Date and time delimiter when generating strings.
|
2017-02-22 17:09:02 +01:00
|
|
|
SQChar m_DateDelim; // Date component delimiter when generating strings.
|
|
|
|
SQChar m_TimeDelim; // Time component delimiter when generating strings.
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Compare the values of two instances.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Compare(const Datetime & o) const;
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Default constructor.
|
|
|
|
*/
|
|
|
|
Datetime()
|
|
|
|
: m_Year(1970)
|
|
|
|
, m_Month(1)
|
|
|
|
, m_Day(1)
|
|
|
|
, m_Hour(0)
|
|
|
|
, m_Minute(0)
|
|
|
|
, m_Second(0)
|
|
|
|
, m_Millisecond(0)
|
|
|
|
, m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific year constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
explicit Datetime(uint16_t year)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, 1, 1, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific year and month constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, 1, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific date constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month, uint8_t day)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, day, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific date and hour constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, day, hour, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific date, hour and minute constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, day, hour, minute, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific date and time constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, day, hour, minute, second, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
* Specific date and precise time constructor.
|
2016-06-04 18:17:42 +02:00
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond)
|
2016-06-04 18:17:42 +02:00
|
|
|
: m_Delimiter(Delimiter)
|
|
|
|
, m_DateDelim(DateDelim)
|
|
|
|
, m_TimeDelim(TimeDelim)
|
|
|
|
{
|
|
|
|
Set(year, month, day, hour, minute, second, millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy constructor.
|
|
|
|
*/
|
|
|
|
Datetime(const Datetime & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor.
|
|
|
|
*/
|
|
|
|
Datetime(Datetime && o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destructor.
|
|
|
|
*/
|
|
|
|
~Datetime() = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
|
|
|
Datetime & operator = (const Datetime & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
|
|
|
Datetime & operator = (Datetime && o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Equality comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator == (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Inequality comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator != (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Less than comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator < (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Greater than comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator > (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Less than or equal comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator <= (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) <= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Greater than or equal comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator >= (const Datetime & o) const
|
|
|
|
{
|
|
|
|
return Compare(o) >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Addition operator.
|
|
|
|
*/
|
|
|
|
Datetime operator + (const Datetime & o) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Subtraction operator.
|
|
|
|
*/
|
|
|
|
Datetime operator - (const Datetime & o) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Multiplication operator.
|
|
|
|
*/
|
|
|
|
Datetime operator * (const Datetime & o) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Division operator.
|
|
|
|
*/
|
|
|
|
Datetime operator / (const Datetime & o) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare two instances of this type.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD int32_t Cmp(const Datetime & o) const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return Compare(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String ToString() const;
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, m_Month, m_Day, m_Hour, m_Minute, m_Second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, month, m_Day, m_Hour, m_Minute, m_Second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month, uint8_t day)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, month, day, m_Hour, m_Minute, m_Second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month, uint8_t day, uint8_t hour)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, month, day, hour, m_Minute, m_Second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, month, day, hour, minute, m_Second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
Set(year, month, day, hour, minute, second, m_Millisecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Assign the specified values.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void Set(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the local delimiter character.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQChar GetDelimiter() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Delimiter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the local delimiter character.
|
|
|
|
*/
|
|
|
|
void SetDelimiter(SQChar c)
|
|
|
|
{
|
|
|
|
m_Delimiter = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the local date delimiter character.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQChar GetDateDelim() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_DateDelim;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the local date delimiter character.
|
|
|
|
*/
|
|
|
|
void SetDateDelim(SQChar c)
|
|
|
|
{
|
|
|
|
m_DateDelim = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the local time delimiter character.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD SQChar GetTimeDelim() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_TimeDelim;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the local time delimiter character.
|
|
|
|
*/
|
|
|
|
void SetTimeDelim(SQChar c)
|
|
|
|
{
|
|
|
|
m_TimeDelim = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the values as a string.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD String GetStr() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values from a string.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetStr(const SQChar * str);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the day component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint16_t GetDayOfYear() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return Chrono::DayOfYear(m_Year, m_Month, m_Day);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the day component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetDayOfYear(uint16_t doy);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the year component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint16_t GetYear() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Year;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the year component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetYear(uint16_t year);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the month component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetMonth() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Month;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the month component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMonth(uint8_t month);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the day component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetDay() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Day;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the day component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetDay(uint8_t day);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the hour component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetHour() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Hour;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the hour component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetHour(uint8_t hour);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the minute component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetMinute() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Minute;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the minute component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMinute(uint8_t minute);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the second component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetSecond() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Second;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the second component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetSecond(uint8_t second);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the millisecond component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint16_t GetMillisecond() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return m_Millisecond;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the millisecond component.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
void SetMillisecond(uint16_t millisecond);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of years to the current date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddYears(int32_t years);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of months to the current date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddMonths(int32_t months);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of days to the current date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddDays(int32_t days);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of hours to the current time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddHours(int32_t hours);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of minutes to the current time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddMinutes(int32_t minutes);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of seconds to the current time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddSeconds(int32_t seconds);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of milliseconds to the current time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
Datetime & AddMilliseconds(int32_t milliseconds);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of years to obtain a new date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndYears(int32_t years);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of months to obtain a new date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndMonths(int32_t months);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of days to obtain a new date.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndDays(int32_t days);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of hours to obtain a new time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndHours(int32_t hours);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of minutes to obtain a new time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndMinutes(int32_t minutes);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of seconds to obtain a new time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndSeconds(int32_t seconds);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Add the specified amount of milliseconds to obtain a new time.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Datetime AndMilliseconds(int32_t milliseconds);
|
2016-06-04 18:17:42 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* See whether the associated year is a leap year.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD bool IsThisLeapYear() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return Chrono::IsLeapYear(m_Year);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the number of days in the associated year.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint16_t GetYearDays() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return Chrono::DaysInYear(m_Year);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the number of days in the associated month.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD uint8_t GetMonthDays() const
|
2016-06-04 18:17:42 +02:00
|
|
|
{
|
|
|
|
return Chrono::DaysInMonth(m_Year, m_Month);
|
|
|
|
}
|
|
|
|
|
2016-06-04 21:33:34 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the date from this date-time instance.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Date GetDate() const;
|
2016-06-04 21:33:34 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the time from this date-time instance.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Time GetTime() const;
|
2016-06-04 21:33:34 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Convert this date-time instance to a time-stamp.
|
|
|
|
*/
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
2016-06-04 18:17:42 +02:00
|
|
|
};
|
2016-03-25 13:28:07 +01:00
|
|
|
|
|
|
|
} // Namespace:: SqMod
|