Add a DateTime method to return all a list of all datetimes within a range. The method could take in start and end date, and the period for the range.
Do I understand it correctly that what you want is basically:
c#
static IEnumerable<DateTime> Range(DateTime start, DateTime end, TimeSpan period)
{
for (DateTime current = start; current <= end; current += period)
yield return current;
}
To me something like that appears to be too simple and not useful often enough to be worth adding to .Net.
Aside from @svick's comment:
@prkhandelwal see API Review Process for adding a formal proposal.
Side note: @svick 's implementation may produce surprising results if DateTimeKind is Local, because it won't account for DST changes.
A mismatch in DateTimeKind between start and end may also produce surprising results, particularly if one of them is Unknown.
You would be better off using DateTimeOffset (or switching to NodaTime).
In addition to @svick's recommendation, I've had good results using ncrontab for more advanced needs.
@scalablecory - from the look of that library, it'll fall into (at least some of) the same issues as the earlier recommendation wrt DST.
Most helpful comment
Do I understand it correctly that what you want is basically:
c# static IEnumerable<DateTime> Range(DateTime start, DateTime end, TimeSpan period) { for (DateTime current = start; current <= end; current += period) yield return current; }To me something like that appears to be too simple and not useful often enough to be worth adding to .Net.