Make DateTime::now() and DateTime::gmtNow() inline

This commit is contained in:
Martchus 2016-05-08 20:36:26 +02:00
parent 7bb6875ded
commit 76e422a7ce
2 changed files with 17 additions and 17 deletions

View File

@ -5,7 +5,6 @@
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <ctime>
using namespace std;
using namespace ChronoUtilities;
@ -35,22 +34,6 @@ inline bool inRangeExclMax(num1 val, num2 min, num3 max)
return (val) >= (min) && (val) < (max);
}
/*!
* \brief Returns a DateTime object that is set to the current date and time on this computer, expressed as the local time.
*/
DateTime DateTime::now()
{
return DateTime::fromTimeStamp(time(nullptr));
}
/*!
* \brief Returns a DateTime object that is set to the current date and time on this computer, expressed as the GMT time.
*/
DateTime DateTime::gmtNow()
{
return DateTime::fromTimeStampGmt(time(nullptr));
}
/*!
* \class ChronoUtilities::DateTime
* \brief Represents an instant in time, typically expressed as a date and time of day.

View File

@ -7,6 +7,7 @@
#include <string>
#include <limits>
#include <ctime>
namespace ChronoUtilities
{
@ -315,6 +316,22 @@ constexpr inline DateTime DateTime::eternity()
return DateTime(std::numeric_limits<decltype(m_ticks)>::max());
}
/*!
* \brief Returns a DateTime object that is set to the current date and time on this computer, expressed as the local time.
*/
inline DateTime DateTime::now()
{
return DateTime::fromTimeStamp(time(nullptr));
}
/*!
* \brief Returns a DateTime object that is set to the current date and time on this computer, expressed as the GMT time.
*/
inline DateTime DateTime::gmtNow()
{
return DateTime::fromTimeStampGmt(time(nullptr));
}
/*!
* \brief Indicates whether two DateTime instances are equal.
*/