mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[traffic] Add IsoTime::IsPast()
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user