From 1b88257ce4c4a12b122ad1e6f2daf66d765cebac Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 28 Oct 2018 13:06:12 +0100 Subject: [PATCH] fix xmltv time offsets Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7e5029e75dcab4aab82edd256b8ed3d070d1b9af Author: TangoCash Date: 2018-10-28 (Sun, 28 Oct 2018) --- src/eitd/xmlutil.cpp | 14 +++++++++++--- src/nhttpd/tuxboxapi/controlapi.cpp | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index 10c2df69e..0b8c4f798 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -477,10 +477,18 @@ bool readEventsFromXMLTV(std::string &epgname, int &ev_count) struct tm starttime, stoptime; strptime(start, "%Y%m%d%H%M%S %z", &starttime); strptime(stop, "%Y%m%d%H%M%S %z", &stoptime); - time_t start_time = mktime(&starttime); - time_t duration = mktime(&stoptime)-start_time; + time_t start_time = mktime(&starttime) + starttime.tm_gmtoff; + time_t duration = mktime(&stoptime) + starttime.tm_gmtoff - start_time; + + t_channel_id epgid = 0; + time_t current_time; + time(¤t_time); + time_t time_diff = current_time - (start_time + duration); + + // just loads events if they end is in the future + if (time_diff < 0) + epgid = getepgid(chan); - t_channel_id epgid = getepgid(chan); if (epgid != 0) { //printf("\e[1;34m%s - %d - %s 0x%012" PRIx64 "(%ld) (%ld)\e[0m\n",__func__, __LINE__,chan, epgid, start_time, duration); diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 4fda19735..5eeab4725 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -3278,11 +3278,11 @@ void CControlAPI::xmltvepgCGI(CyhookHandler *hh) programmeTag = "programme "; programmeTag += "channel=\""+string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id)+"\" "; char zbuffer[25] = { 0 }; - struct tm *mtime = localtime(&eventIterator->startTime); + struct tm *mtime = gmtime(&eventIterator->startTime); strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); programmeTag += "start=\""+std::string(zbuffer)+"\" "; long _stoptime = eventIterator->startTime + eventIterator->duration; - mtime = localtime(&_stoptime); + mtime = gmtime(&_stoptime); strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); programmeTag += "stop=\""+std::string(zbuffer)+"\" ";