示例#1
0
        public static ScheduleMatchData GetScheduleWeighting(redux_items redux, pips_programmes pips)
        {
            ScheduleMatchData data = new ScheduleMatchData();

            data.StartDistance = Math.Abs((redux.aired - pips.start_gmt).TotalSeconds);
            data.DurationDelta = Math.Abs(redux.duration - (pips.end_gmt - pips.start_gmt).TotalSeconds);
            DateTime maxstart = pips.start_gmt;

            if (redux.aired > pips.start_gmt)
            {
                maxstart = redux.aired;
            }

            DateTime minend = pips.end_gmt;

            if (redux.aired.AddSeconds(redux.duration) < minend)
            {
                minend = redux.aired.AddSeconds(redux.duration);
            }

            var overlap = minend - maxstart;

            if (overlap.TotalSeconds < 0)
            {
                data.OverlapWeight = 0.0;
            }
            else
            {
                data.OverlapWeight = 100.0 * (overlap.TotalSeconds / (double)redux.duration) + 100.0 * (overlap.TotalSeconds / (pips.end_gmt - pips.start_gmt).TotalSeconds);
            }
            return(data);
        }
示例#2
0
        public static ScheduleMatchData GetScheduleWeighting(redux_items redux, pips_programmes pips)
        {
            ScheduleMatchData data = new ScheduleMatchData();
            data.StartDistance = Math.Abs((redux.aired - pips.start_gmt).TotalSeconds);
            data.DurationDelta = Math.Abs(redux.duration - (pips.end_gmt - pips.start_gmt).TotalSeconds);
            DateTime maxstart = pips.start_gmt;
            if (redux.aired > pips.start_gmt)
            {
                maxstart = redux.aired;
            }

            DateTime minend = pips.end_gmt;
            if (redux.aired.AddSeconds(redux.duration) < minend)
            {
                minend = redux.aired.AddSeconds(redux.duration);
            }

            var overlap = minend - maxstart;
            if (overlap.TotalSeconds < 0)
            {
                data.OverlapWeight = 0.0;
            }
            else
            {
                data.OverlapWeight = 100.0 * (overlap.TotalSeconds / (double)redux.duration) + 100.0 * (overlap.TotalSeconds / (pips.end_gmt - pips.start_gmt).TotalSeconds);
            }
            return data;
        }