diff --git a/Makefile b/Makefile index 27be359..25e2876 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ MAKE=gmake DEFS=-D_REENTRANT -D_TS_ERRNO -DHMT_PROTECT # -DWITH_MPATROL -SRCS= descriptor.c \ +SRCS= bst.c \ + descriptor.c \ epg.c \ file.c \ huffman.c \ diff --git a/bst.c b/bst.c new file mode 100644 index 0000000..c5b338c --- /dev/null +++ b/bst.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lint.h" + +struct bsttab { + time_t tm; + int bst; +}; + +#include "bst.h" + +int +is_bst(time_t tm) +{ + int i, is_bst; + + is_bst = 0; + for (i = 0; bst[i].tm; i++) + { + if (bst[i].tm > tm) + break; + is_bst = bst[i].bst; + } + + return is_bst; +} + +void +bstise(time_t *tm) +{ + if (is_bst(*tm)) + *tm += 3600; +} + diff --git a/bst.h b/bst.h new file mode 100644 index 0000000..7cec365 --- /dev/null +++ b/bst.h @@ -0,0 +1,21 @@ +struct bsttab bst[] = { + { 1301187600, 1 }, + { 1319936400, 0 }, + { 1332637200, 1 }, + { 1351386000, 0 }, + { 1364691600, 1 }, + { 1382835600, 0 }, + { 1396141200, 1 }, + { 1414285200, 0 }, + { 1427590800, 1 }, + { 1445734800, 0 }, + { 1459040400, 1 }, + { 1477789200, 0 }, + { 1490490000, 1 }, + { 1509238800, 0 }, + { 1521939600, 1 }, + { 1540688400, 0 }, + { 1553994000, 1 }, + { 1572138000, 0 }, + { 0, 0 }, +}; diff --git a/lint.h b/lint.h index 01ace19..7443e66 100644 --- a/lint.h +++ b/lint.h @@ -44,6 +44,9 @@ void free_descriptor(struct descriptor *); unsigned char *freeview_huffman_to_string(const unsigned char *, uint, unsigned int *); +int is_bst(time_t); +void bstise(time_t *); + #ifdef sun char *strcasestr (char *, char *); #endif diff --git a/main.c b/main.c index 0b18b5e..8c172b2 100644 --- a/main.c +++ b/main.c @@ -82,6 +82,7 @@ dump(struct epg *epg __attribute__((unused)), time_t tm; tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec); + bstise(&tm); if (ds[PARSER_SHORT_EVENT]) { diff --git a/mkbst b/mkbst new file mode 100755 index 0000000..276e10b --- /dev/null +++ b/mkbst @@ -0,0 +1,17 @@ +#!/bin/sh + +# Generate British Summer Time switchover table + +year=2011 + +echo "struct bsttab bst[] = {" +while [ $year -lt 2020 ]; do + dststart=`cal 3 $year | grep '[0-9]' | tail -1 | awk '{print $1}'` + dstend=`cal 10 $year | grep '[0-9]' | tail -1 | awk '{print $1}'` + echo " { `date -d ${year}03${dststart}0100 +%s`, 1 }," + echo " { `date -d ${year}10${dstend}0100 +%s`, 0 }," + year=`expr $year + 1` +done +echo " { 0, 0 }," +echo "};" +