private static IEnumerable <string> ResolveDefiniteAgainstConstraint(TimexProperty timex, DateRange constraint)
        {
            var timexDate = TimexHelpers.DateFromTimex(timex);

            if (timexDate >= constraint.Start && timexDate < constraint.End)
            {
                return(new[] { timex.TimexValue });
            }

            return(Enumerable.Empty <string>());
        }
        private static IEnumerable <string> ResolveDateAgainstConstraint(TimexProperty timex, DateRange constraint)
        {
            if (timex.Month != null && timex.DayOfMonth != null)
            {
                var result = new List <string>();
                for (var year = constraint.Start.Year; year <= constraint.End.Year; year++)
                {
                    var t = timex.Clone();
                    t.Year = year;
                    result.AddRange(ResolveDefiniteAgainstConstraint(t, constraint));
                }

                return(result);
            }

            if (timex.DayOfWeek != null)
            {
                var day    = timex.DayOfWeek == 7 ? DayOfWeek.Monday : (DayOfWeek)timex.DayOfWeek;
                var dates  = TimexDateHelpers.DatesMatchingDay(day, constraint.Start, constraint.End);
                var result = new List <string>();

                foreach (var d in dates)
                {
                    var t = timex.Clone();
                    t.DayOfWeek  = null;
                    t.Year       = d.Year;
                    t.Month      = d.Month;
                    t.DayOfMonth = d.Day;
                    result.Add(t.TimexValue);
                }

                return(result);
            }

            return(Enumerable.Empty <string>());
        }
Beispiel #3
0
 private static bool IsOverlapping(DateRange r1, DateRange r2)
 {
     return(r1.End > r2.Start && r1.Start <= r2.Start ||
            r1.Start < r2.End && r1.Start >= r2.Start);
 }