Class DateTimeRanges
Represents a collection of ranges for DateTime values, with parsing support from string representations.
public class DateTimeRanges : Ranges<DateTime>, IFormattable, IEquatable<Ranges<DateTime>>, ISubtractionOperators<Ranges<DateTime>, Ranges<DateTime>, Ranges<DateTime>>, IEqualityOperators<Ranges<DateTime>, Ranges<DateTime>, bool>
- Inheritance
-
DateTimeRanges
- Implements
- Inherited Members
- Extension Methods
Constructors
DateTimeRanges()
Initializes a new instance of the DateTimeRanges class with no ranges.
public DateTimeRanges()
DateTimeRanges(IEnumerable<IRange<DateTime>>)
Initializes a new instance of the DateTimeRanges class with interface-based ranges.
public DateTimeRanges(IEnumerable<IRange<DateTime>> ranges)
Parameters
rangesIEnumerable<IRange<DateTime>>The ranges to include in the collection.
DateTimeRanges(IEnumerable<Range<DateTime>>)
Initializes a new instance of the DateTimeRanges class with ranges provided as an enumerable collection.
public DateTimeRanges(IEnumerable<Range<DateTime>> ranges)
Parameters
rangesIEnumerable<Range<DateTime>>The ranges to include in the collection.
DateTimeRanges(Ranges<DateTime>)
Initializes a new instance of the DateTimeRanges class by copying an existing set of ranges.
public DateTimeRanges(Ranges<DateTime> ranges)
Parameters
DateTimeRanges(params Range<DateTime>[])
Initializes a new instance of the DateTimeRanges class with the specified ranges.
public DateTimeRanges(params Range<DateTime>[] ranges)
Parameters
Methods
Add(string)
Adds ranges to the collection by parsing them from a string using the current culture.
public void Add(string ranges)
Parameters
rangesstringThe string representation of the ranges to add.
Add(string, CultureInfo)
Adds ranges to the collection by parsing them from a string using a specified culture.
public void Add(string ranges, CultureInfo cultureInfo)
Parameters
rangesstringThe string representation of the ranges to add.
cultureInfoCultureInfoThe culture information to use for parsing.
Add(string, DateTimeFormatInfo)
Adds ranges to the collection by parsing them from a string using a specified DateTime format.
public void Add(string ranges, DateTimeFormatInfo formatInfo)
Parameters
rangesstringThe string representation of the ranges to add.
formatInfoDateTimeFormatInfoThe DateTime format information to use for parsing.
InnerParse(string, DateTimeFormatInfo)
Helper method to parse ranges from a string using specified DateTime format information.
protected static IEnumerable<IRange<DateTime>> InnerParse(string range, DateTimeFormatInfo formatInfo)
Parameters
rangestringThe string representation of the ranges.
formatInfoDateTimeFormatInfoThe DateTime format information to use for parsing.
Returns
- IEnumerable<IRange<DateTime>>
An enumerable collection of Range<DateTime> objects parsed from the string.
Parse(string)
Parses a string representation of ranges into a DateTimeRanges object using the current culture.
public static DateTimeRanges Parse(string range)
Parameters
rangestringThe string representation of the ranges.
Returns
- DateTimeRanges
A DateTimeRanges object containing the parsed ranges.
Parse(string, CultureInfo)
Parses a string representation of ranges into a DateTimeRanges object using a specified culture.
public static DateTimeRanges Parse(string range, CultureInfo cultureInfo)
Parameters
rangestringThe string representation of the ranges.
cultureInfoCultureInfoThe culture information to use for parsing.
Returns
- DateTimeRanges
A DateTimeRanges object containing the parsed ranges.