using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.Dvb.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0x69,"EIT")]
    [BannedTable("PMT","TSDT")]
    class PdcDescriptor : TsDescriptor
    {
        public PdcDescriptor(byte[] buffer)
        {
            int tmp = buffer[0];
            tmp <<= 8;
            tmp += buffer[1];
            tmp <<= 8;
            tmp += buffer[2];

            Minute = (tmp & 0x0000003f);
            Hour =   (tmp & 0x000007c0) >> 6;
            Month =  (tmp & 0x00007800) >> 11;
            Day =    (tmp & 0x000f8000) >> 15;
            this.Valid = !((Month > 12) || (Hour > 23) || (Minute > 59) || (Day > 30));
        }

        public int Day { get; private set; }

        public int Month { get; private set; }

        public int Hour { get; private set; }

        public int Minute { get; private set; }
        
    }
}
