public static class DateExtensions
public static DateTime Max(params DateTime[] dates)
public static DateTime Min(params DateTime[] dates)
public readonly struct DateRange
public DateRange(DateTime from, DateTime to)
if (from.Kind != to.Kind)
throw new ArgumentException("DateTime args has different Kind");
public DateTime Start { get; init; }
public DateTime End { get; init; }
public static class DateRangeExtensions
public static DateRange RangeAscending(this TimeSpan time)
=> new(DateTime.Now.Subtract(time), DateTime.Now);
public static void Main()
Console.WriteLine("Hello World");
var range = TimeSpan.FromDays(14).RangeAscending();
const int daysPortion = 10;
for (DateTime f = range.Start.Date, t = f.AddDays(daysPortion); t <= range.End.Date; f = f.AddDays(daysPortion), t = DateExtensions.Min(t.AddDays(daysPortion), range.End.Date))
Console.WriteLine($"{f} ---- {t}");