diff --git a/traffxml/traff_model.cpp b/traffxml/traff_model.cpp index 7479f713f..ec981e489 100644 --- a/traffxml/traff_model.cpp +++ b/traffxml/traff_model.cpp @@ -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) { diff --git a/traffxml/traff_model.hpp b/traffxml/traff_model.hpp index 221b0c500..0ab998e94 100644 --- a/traffxml/traff_model.hpp +++ b/traffxml/traff_model.hpp @@ -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: