[traffic] Add IsoTime::IsPast()

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-05-16 17:48:29 +03:00
parent 356b051036
commit 136293c308
2 changed files with 15 additions and 0 deletions

View File

@@ -138,6 +138,12 @@ IsoTime::IsoTime(std::tm tm)
: m_tm(tm)
{}
bool IsoTime::IsPast()
{
std::time_t t_now = std::time(nullptr);
std::time_t t_tm = timegm(&m_tm);
return t_tm < t_now;
}
bool operator< (IsoTime lhs, IsoTime rhs)
{

View File

@@ -65,6 +65,15 @@ public:
*/
static IsoTime Now();
/**
* @brief Whether the instance refers to a point of time in the past.
*
* Comparison is against system time.
*
* @return true if in the past, false of not.
*/
bool IsPast();
friend bool operator< (IsoTime lhs, IsoTime rhs);
friend bool operator> (IsoTime lhs, IsoTime rhs);
private: