Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGES.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.96.6 (unreleased)
-------------------
- Fix: DVB EIT start time BCD decoding in XMLTV output causing invalid timestamps (#1835)
- New: Add Snap packaging support with Snapcraft configuration and GitHub Actions CI workflow.
- Fix: Clear status line output on Linux/WSL to prevent text artifacts (#2017)
- Fix: Prevent infinite loop on truncated MKV files
Expand Down
28 changes: 27 additions & 1 deletion src/lib_ccx/ts_tables_epg.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void EPG_DVB_calc_start_time(struct EPG_event *event, uint64_t time)
if (mjd > 0)
{
long y, m, d, k;
struct tm timeinfo = {0};

// algo: ETSI EN 300 468 - ANNEX C
y = (long)((mjd - 15078.2) / 365.25);
Expand All @@ -145,7 +146,32 @@ void EPG_DVB_calc_start_time(struct EPG_event *event, uint64_t time)
y = y + k + 1900;
m = m - 1 - k * 12;

snprintf(event->start_time_string, sizeof(event->start_time_string), "%02ld%02ld%02ld%06" PRIu64 "+0000", y, m, d, time & 0xffffff);
timeinfo.tm_year = y - 1900;
timeinfo.tm_mon = m - 1;
timeinfo.tm_mday = d;

// Decode BCD time (lower 24 bits: HHMMSS)
uint32_t bcd = (uint32_t)(time & 0xFFFFFF);

timeinfo.tm_sec = (bcd & 0x0f) + (10 * ((bcd & 0xf0) >> 4));

timeinfo.tm_min = ((bcd & 0x0f00) >> 8) + (10 * ((bcd & 0xf000) >> 12));

timeinfo.tm_hour = ((bcd & 0x0f0000) >> 16) + (10 * ((bcd & 0xf00000) >> 20));

timeinfo.tm_isdst = -1;

mktime(&timeinfo);

snprintf(event->start_time_string,
sizeof(event->start_time_string),
"%04d%02d%02d%02d%02d%02d +0000",
timeinfo.tm_year + 1900,
timeinfo.tm_mon + 1,
timeinfo.tm_mday,
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec);
}
}

Expand Down
Loading