eitd/SIutils.cpp: add parseDVBtime function

Origin commit data
------------------
Branch: ni/coolstream
Commit: 87037520de
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-02-08 (Wed, 08 Feb 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2012-02-08 18:20:28 +04:00
parent 5425c7d855
commit d1358d7cc7
2 changed files with 35 additions and 0 deletions

View File

@@ -85,6 +85,8 @@
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include "SIutils.hpp"
// Thanks to kwon // Thanks to kwon
time_t changeUTCtoCtime(const unsigned char *buffer, int local_time) time_t changeUTCtoCtime(const unsigned char *buffer, int local_time)
{ {
@@ -128,6 +130,36 @@ time_t changeUTCtoCtime(const unsigned char *buffer, int local_time)
return mktime(&time) + (local_time ? -timezone : 0); return mktime(&time) + (local_time ? -timezone : 0);
} }
time_t parseDVBtime(uint16_t mjd, uint32_t bcd)
{
int year, month, day, y_, m_, k, hour, minutes, seconds;
y_ = (int) ((mjd - 15078.2) / 365.25);
m_ = (int) ((mjd - 14956.1 - (int) (y_ * 365.25)) / 30.6001);
day = mjd - 14956 - (int) (y_ * 365.25) - (int) (m_ * 30.60001);
hour = (bcd >> 16) & 0xFF;
minutes = (bcd >> 8) & 0xFF;
seconds = bcd & 0xFF;
k = !!((m_ == 14) || (m_ == 15));
year = y_ + k + 1900;
month = m_ - 1 - k * 12;
struct tm time;
memset(&time, 0, sizeof(struct tm));
time.tm_mday = day;
time.tm_mon = month - 1;
time.tm_year = year - 1900;
time.tm_hour = (hour >> 4) * 10 + (hour & 0x0f);
time.tm_min = (minutes >> 4) * 10 + (minutes & 0x0f);
time.tm_sec = (seconds >> 4) * 10 + (seconds & 0x0f);
return mktime(&time) - timezone;
}
// Thanks to tmbinc // Thanks to tmbinc
int saveStringToXMLfile(FILE *out, const char *c, int /*withControlCodes*/) int saveStringToXMLfile(FILE *out, const char *c, int /*withControlCodes*/)
{ {

View File

@@ -44,7 +44,10 @@
// Alles neu macht der Mai. // Alles neu macht der Mai.
// //
// //
#include <stdint.h>
time_t changeUTCtoCtime(const unsigned char *buffer, int local_time=1); time_t changeUTCtoCtime(const unsigned char *buffer, int local_time=1);
time_t parseDVBtime(uint16_t mjd, uint32_t bcd);
// returns the descriptor type as readable text // returns the descriptor type as readable text
const char *decode_descr (unsigned char tag_value); const char *decode_descr (unsigned char tag_value);