From 2e2804214a97a6fac527d90652b82238a769e67f Mon Sep 17 00:00:00 2001 From: horchi Date: Fri, 14 Feb 2020 08:24:22 +0100 Subject: fixed time handling for timer --- lib/common.c | 5 +++++ lib/common.h | 1 + ttools.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/common.c b/lib/common.c index 2793537..e6bafae 100644 --- a/lib/common.c +++ b/lib/common.c @@ -672,6 +672,11 @@ int l2hhmm(time_t t) return tm.tm_hour * 100 + tm.tm_min; } +time_t hhmm2L(int hhmm, time_t offset) +{ + return ((hhmm/100) * tmeSecondsPerHour) + ((hhmm%100) * tmeSecondsPerMinute) + offset; +} + //*************************************************************************** // HHMM to Pretty Time //*************************************************************************** diff --git a/lib/common.h b/lib/common.h index c8361ec..27c1772 100644 --- a/lib/common.h +++ b/lib/common.h @@ -292,6 +292,7 @@ const char* toWeekdayName(uint day); time_t hhmmOf(time_t t); int l2hhmm(time_t t); std::string hhmm2pTime(int hhmm); +time_t hhmm2L(int hhmm, time_t offset = 0); time_t midnightOf(time_t t); std::string l2pTime(time_t t, const char* format = "%d.%m.%Y %T"); std::string l2pDate(time_t t); diff --git a/ttools.c b/ttools.c index f48135d..168fe63 100644 --- a/ttools.c +++ b/ttools.c @@ -329,10 +329,13 @@ int updateRowByTimer(cDbRow* timerRow, const cTimer* t) contentOfTag(t, "directory", directory, 512); contentOfTag(t, "source", source, 40); + time_t startTime = hhmm2L(t->Start(), t->Day()); + time_t endTime = hhmm2L(t->Stop(), t->Day() + t->Stop() < t->Start() ? tmeSecondsPerDay : 0); + timerRow->setValue("VDRUUID", Epg2VdrConfig.uuid); timerRow->setValue("EVENTID", t->Event() ? (long)t->Event()->EventID() : 0); - timerRow->setValue("_STARTTIME", t->Event() ? t->Event()->StartTime() : 0); - timerRow->setValue("_ENDTIME", t->Event() ? t->StopTime() : 0); + timerRow->setValue("_STARTTIME", startTime); + timerRow->setValue("_ENDTIME", endTime); timerRow->setValue("CHANNELID", channelId); timerRow->setValue("DAY", t->Day()); timerRow->setValue("STARTTIME", t->Start()); -- cgit v1.2.3