public static bool IntersectsWith(this IDateSpan source, IDateSpan other) { if ((source == null) || (other == null)) { return false; } return (((other.Start <= source.Start) && (source.Start < other.End)) || ((source.Start <= other.Start) && (other.Start < source.End))); }
private void SetRangeOfWeeks() { IDateSpan range = ScheduleView.VisibleRange; _firstWeek = CreateSevenDaysWeek(range.Start, true); _secondWeek = CreateSevenDaysWeek(_firstWeek.End, false); _thirdWeek = CreateSevenDaysWeek(_secondWeek.End, false); _fourthWeek = CreateSevenDaysWeek(_thirdWeek.End, false); _fifthWeek = CreateSevenDaysWeek(_fourthWeek.End, false); }
private static IEnumerable <AppointmentSlot> CreateAppointmentSlots( TimeSlotCollectionView timeSlots, IDateSpan intersection, Func <TimeSlot, AppointmentSlot> slotCreator) { return (from g in timeSlots.Groups let intersected = from slot in g.TimeSlots where intersection.IntersectsWith(slot) select slot where intersected.Count() > 0 select slotCreator(new TimeSlotGroup(intersected))); }
private void GenerateAppointments(IDateSpan dateSpan) { ObservableCollection<Appointment> newSource = new ObservableCollection<Appointment>(); newSource.AddRange( from i in Enumerable.Range(0, (dateSpan.End - dateSpan.Start).Days * 24) select new Appointment() { Subject = "Appointment" + i + " " + dateSpan.Start.AddHours(i).ToShortDateString(), Start = dateSpan.Start.AddHours(i), End = dateSpan.Start.AddHours(i + 1), }); this.Appointments = newSource; }
public ScheduleRuleSpan(IDateSpan[] dates, ScheduleRule[] rules) { Dates = dates; Rules = rules; }
public DateSpan(IDateSpan other) { this.start = other.Start; this.end = other.End; }
/// <summary> /// Validates the specified date span. /// </summary> /// <param name="dateSpan">The date span.</param> /// <returns></returns> public static bool Validate(this IDateSpan dateSpan) { return((dateSpan.Start != DateTime.MinValue) && (dateSpan.End != DateTime.MaxValue) && dateSpan.Start <= dateSpan.End); }
/// <summary> /// Subtracts the interval. /// </summary> /// <param name="dateSpan">The date span.</param> /// <param name="dateTimeInterval">The date time interval.</param> /// <returns></returns> public static TimeSlot SubtractInterval(this IDateSpan dateSpan, DateTimeInterval dateTimeInterval) { return(new TimeSlot( dateSpan.Start.AddDays(-dateTimeInterval.Days).AddMonths(-dateTimeInterval.Months), dateSpan.End.AddDays(-dateTimeInterval.Days).AddMonths(-dateTimeInterval.Months))); }
/// <summary> /// <c>Intersectses</c> the with. /// </summary> /// <param name="source">The source.</param> /// <param name="other">The other.</param> /// <returns></returns> public static bool IntersectsWith(this IDateSpan source, IDateSpan other) { return((other.Start <= source.Start && source.Start < other.End) || (source.Start <= other.Start && other.Start < source.End)); }
/// <summary> /// Gets the duration of the specified date span. /// </summary> /// <param name="dateSpan">The date span.</param> /// <returns>Duration of the date span as devision of end and start.</returns> public static TimeSpan Duration(this IDateSpan dateSpan) { return(dateSpan.End - dateSpan.Start); }
/// <summary> /// Determines whether <see cref="DateSpan"/> contains <see cref="DateTime"/>. /// </summary> /// <param name="source">The source.</param> /// <param name="date">The date.</param> /// <returns> /// <c>true</c> if contains date; otherwise, <c>false</c>. /// </returns> public static bool Contains(this IDateSpan source, DateTime date) { return(source.Start <= date && date < source.End); }
/// <summary> /// Determines whether <see cref="DateSpan"/> contains another <see cref="DateSpan"/>. /// </summary> /// <param name="source">The source.</param> /// <param name="other">The other.</param> /// <returns> /// <c>true</c> if contains another <see cref="DateSpan"/>; otherwise, <c>false</c>. /// </returns> public static bool Contains(this IDateSpan source, IDateSpan other) { return(source.Start <= other.Start && source.End >= other.End); }
public static bool ContainsPartialInclusive(this IDateSpan source, IDateSpan other) { return ContainsInclusive(source, other.Start) || ContainsInclusive(source, other.End); }
public static bool ContainsInclusive(this IDateSpan source, IDateSpan other) { return ((source.Start <= other.Start) && (source.End >= other.End)); }
public static bool Contains(this IDateSpan source, IDateSpan other) { return ((source.Start < other.Start) && (source.End > other.End)); }