Skip to content

DateRangeExtensions

The library's date-range algorithm surface: equality, open-endedness, overlap and contiguity testing, and range filtering, operating on IDateRange/IEnumerable<IDateRange>. (BR-001, BR-003, BR-004, BR-005) through BR-011, BR-034, BR-036, BR-037

Purpose

  • The library's date-range algorithm surface: equality, open-endedness, overlap and contiguity testing, and range filtering, operating on IDateRange/IEnumerable<IDateRange>. (BR-001, BR-003, BR-004, BR-005) through BR-011, BR-034, BR-036, BR-037

Context

  • Namespace: SAIF.Common.Extensions
  • Assembly/package: SAIF.Framework.Common

Public members

Member Signature Purpose
IsEqual(this IDateRange source, IDateRange other) public static bool IsEqual(this IDateRange source, IDateRange other) Value-equality check between two ranges. (BR-034)
IsOpenEnded(this IDateRange source) public static bool IsOpenEnded(this IDateRange source) True when the range's end date is a max/sentinel value indicating no defined end.
IsOverlapping(this IDateRange source, IDateRange other, OverlappingDateOptions options) public static bool IsOverlapping(this IDateRange source, IDateRange other, OverlappingDateOptions options) Tests two ranges for overlap, honoring whether shared boundary dates count as overlapping. (BR-004)
IsValidRange(this IDateRange source) public static bool IsValidRange(this IDateRange source) True when BeginDate <= EndDate.
IsFutureRange(this IDateRange source) public static bool IsFutureRange(this IDateRange source) True when the entire range lies in the future.
IsPastRange(this IDateRange source) public static bool IsPastRange(this IDateRange source) True when the entire range lies in the past.
IsInRange(this DateTime date, IDateRange range) public static bool IsInRange(this DateTime date, IDateRange range) True when date falls within the range's boundaries, inclusive. (BR-036, BR-037)
IsInRange(this IDateRange source, IDateRange other) public static bool IsInRange(this IDateRange source, IDateRange other) True when source falls entirely within other.
AsOf(this IEnumerable source, DateTime asOfDate) public static IEnumerable<T> AsOf<T>(this IEnumerable<T> source, DateTime asOfDate) where T : IDateRange Filters a collection of ranges to those effective as of asOfDate.
ContainsDateRange(this IEnumerable source, IDateRange target) public static bool ContainsDateRange(this IEnumerable<IDateRange> source, IDateRange target) True when any range in the collection matches target exactly.
ContainsBeginDate(this IEnumerable source, DateTime beginDate) public static bool ContainsBeginDate(this IEnumerable<IDateRange> source, DateTime beginDate) True when any range in the collection has the given BeginDate.
IsContiguous(this IEnumerable source, ContiguousOptions options) public static bool IsContiguous(this IEnumerable<IDateRange> source, ContiguousOptions options) Tests whether an ordered sequence of ranges forms an unbroken (or gap-tolerant, per options) chain. (BR-005, BR-006, BR-007)
IsOverLapping(this IEnumerable source) public static bool IsOverLapping(this IEnumerable<IDateRange> source) Tests whether any two ranges within the collection overlap each other. (BR-008, BR-009, BR-010, BR-011)

Sources

  • Common/SAIF.Common/Extensions/DateRangeExtensions.cs