diff options
Diffstat (limited to 'epg_events.cpp')
-rw-r--r-- | epg_events.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/epg_events.cpp b/epg_events.cpp index 3940a57..2619b46 100644 --- a/epg_events.cpp +++ b/epg_events.cpp @@ -1,3 +1,5 @@ +#include <time.h> + #include "tools.h" #include "epg_events.h" @@ -46,6 +48,22 @@ namespace vdrlive return FormatDateTime(format, m_end_time); } + const std::string EpgEvent::CurrentTime(const char* format) const + { + return FormatDateTime(format, time(0)); + } + + int EpgEvent::Elapsed() const + { + if (m_end_time > m_start_time) { + time_t now = time(0); + if ((m_start_time <= now) && (now <= m_end_time)) { + return 100 * (now - m_start_time) / (m_end_time - m_start_time); + } + } + return -1; + } + EpgEvents::EpgEvents() : std::vector<EpgEventPtr>() { |