Add {TimeSpan,DateTime}::ticks() for easier read/write

This commit is contained in:
Martchus 2018-06-23 14:32:46 +02:00
parent e0fee70d58
commit 7b01938ece
2 changed files with 18 additions and 0 deletions

View File

@ -64,6 +64,7 @@ public:
static DateTime fromTimeStamp(time_t timeStamp);
static DateTime fromTimeStampGmt(time_t timeStamp);
uint64 &ticks();
constexpr uint64 totalTicks() const;
int year() const;
int month() const;
@ -212,6 +213,14 @@ inline DateTime DateTime::fromIsoStringLocal(const char *str)
return fromIsoString(str).first;
}
/*!
* \brief Returns a mutable reference to the total ticks.
*/
inline uint64 &DateTime::ticks()
{
return m_ticks;
}
/*!
* \brief Returns the number of ticks which represent the value of the current instance.
*/

View File

@ -42,6 +42,7 @@ public:
static constexpr TimeSpan negativeInfinity();
static constexpr TimeSpan infinity();
int64 &ticks();
constexpr int64 totalTicks() const;
constexpr double totalMicroseconds() const;
constexpr double totalMilliseconds() const;
@ -181,6 +182,14 @@ constexpr inline TimeSpan TimeSpan::infinity()
return TimeSpan(std::numeric_limits<decltype(m_ticks)>::max());
}
/*!
* \brief Returns a mutable reference to the total ticks.
*/
inline int64 &TimeSpan::ticks()
{
return m_ticks;
}
/*!
* \brief Returns the number of ticks that represent the value of the current TimeSpan class.
*/