You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Split a range by a step or period, and Values(step) on the discrete types #100
Python portion has iterate(interval, step); Rust rangemap has StepLite; NodaTime's DateInterval enumerates days; Guava's ContiguousSet enumerates a discrete domain. (portion: https://raw.githubusercontent.com/AlexandreDecan/portion/master/README.md ; NodaTime: https://nodatime.org/3.2.x/api/NodaTime.DateInterval.html .) The library has Values() on the discrete types (one element per step of the domain) and nothing for a step of the consumer's choosing, nor for cutting a range into sub-ranges: the billing months inside a contract period, the 30-minute slots inside opening hours, the ISO weeks of a quarter.
Proposed API (per type, since T arithmetic is not generic):
DateRange.Split(DateRangeStep step) / NodaTime LocalDateRange.Split(Period) → IEnumerable<TRange>: consecutive sub-ranges of the step length, the last one clipped to the range's end.
Values(step) overloads for the discrete types, the stepping form of Values().
Unbounded ranges throw at the call, as Values() does. A calendar-aligned split (first of month, Monday) is where this meets #48 (calendar factories); the two should share the week rule.
Translation: none. generate_series returns rows, not a scalar, which is the documented reason Values() is in-memory only (E31). Say so in docs/efcore.md#what-runs-where.
Done when: Split is documented in docs/ranges.md with the clipping rule, held by claims, and a metamorphic test holds RangeSet.From(range.Split(step)) == RangeSet.From([range]) and that pieces are pairwise adjacent.
Found by the comparable-library survey (portion, rangemap, NodaTime), 2026-10-17.
Decided in #197: the calendar split takes a function, Split(Func<DateOnly, DateRange> period), rather than the sketched DateRangeStep type. contract.Split(DateRange.Month) and quarter.Split(DateRange.IsoWeek) reuse the #48 factories and their ISO week rule. A fiscal year or billing cycle is any function returning the period that holds a day, and the LTS line gets no extra public type. Fixed steps: Split(int days) on DateRange, Split(Period) on LocalDateRange, and the element's own step type elsewhere, each boundary counted from the start.
Activity
CaffeinatedCoder commentedon Oct 18, 2026
Decided in #197: the calendar split takes a function,
Split(Func<DateOnly, DateRange> period), rather than the sketchedDateRangeSteptype.contract.Split(DateRange.Month)andquarter.Split(DateRange.IsoWeek)reuse the #48 factories and their ISO week rule. A fiscal year or billing cycle is any function returning the period that holds a day, and the LTS line gets no extra public type. Fixed steps:Split(int days)onDateRange,Split(Period)onLocalDateRange, and the element's own step type elsewhere, each boundary counted from the start.