using System; using System.Collections.Generic; using System.Linq; using Abp.Timing; namespace Abp.Extensions { /// /// Extension methods for . /// public static class DateTimeRangeExtensions { /// /// Sets date range to given target. /// /// /// public static void SetTo(this IDateTimeRange source, IDateTimeRange target) { target.StartTime = source.StartTime; target.EndTime = source.EndTime; } /// /// Sets date range from given source. /// public static void SetFrom(this IDateTimeRange target, IDateTimeRange source) { target.StartTime = source.StartTime; target.EndTime = source.EndTime; } /// /// Returns all the days of a datetime range. /// /// The date range. /// public static IEnumerable DaysInRange(this IDateTimeRange dateRange) { return Enumerable.Range(0, (dateRange.TimeSpan).Days) .Select(offset => new DateTime( dateRange.StartTime.AddDays(offset).Year, dateRange.StartTime.AddDays(offset).Month, dateRange.StartTime.AddDays(offset).Day)); } /// /// Returns all the days in a range. /// /// The start. /// The end. /// public static IEnumerable DaysInRange(DateTime start, DateTime end) { return new DateTimeRange(start, end).DaysInRange(); } } }