DateRange

Field: static readonly DateRange Default

It is the default value of DateRange. The start time is the smallest Date value. The end time is the largest Date value.

    DateRange.Default; // 1/1/1753 - 12/31/9999

Method: static DateRange Parse(String)

Create a DateRange object with the format yyyyMMdd-yyyyMMdd" and a value of type string

    DateRange dateRange = DateRange.Parse("20170801-20170807");
Parameter Name Description
dateRangeString Date range in yyyyMMdd-yyyyMMdd format.

Error Type: ArgumentNullException (This error is thrown if the value is set to null.)

Error Type: FormatException (This error is thrown If the value does not consist of 17 characters, and if any of the start and end dates can not be parsed to Date type.)


Constructor(Int32, Int32, Int32, Int32, Int32, Int32)

The DateRange object is created with the given start and end date parameters.

Parameter Name Description
startYear Start Year
startMonth Start Month
startDay Start Day
endYear End Year
endMonth End Month
endDay End Day

Error Type: !:RangeException (This error is thrown if the start date is greater than the end date.)


Constructor(Date, Date)

The DateRange object is created with the given start and end date parameters.

Parameter Name Description
start Start date in Date type
end End date in Date type

Error Type: !:RangeException (This error is thrown if the start date is greater than the end date.)


Property: Date Start

Returns the start date of the date in the Date type.


Property: Date End

Returns the end date of the date in the Date type.


Method: bool Contains(Date)

Returns true if the given date is in the DateRange data, false otherwise.

Returns true if the given date is equal to the minimum or maximum value of the DateRange data.

    new DateRange(2017, 8, 1, 2017, 8, 7).Contains(new Date(2017, 8, 5)); //true
    new DateRange(2017, 8, 1, 2017, 8, 7).Contains(new Date(2017, 8, 7)); //true
    new DateRange(2017, 8, 1, 2017, 8, 7).Contains(new Date(2017, 8, 15)); //false
Parameter Name Description
date date parameter in Date type

Method: bool Contains(Date, RangeOptions)

Returns true if the given date is in the DateRange data, false otherwise. If the value of the options parameter is ExcludedStart and the data is equal to the start date, it returns false.

If the value of the options parameter is ExcludedEnd and the data is equal to the end date, it returns false.

If the value of the options parameter is ExcludedStart and ExcludedEnd and the data is equal to the start or end value, it returns false.

    new DateRange(2017, 8, 8, 2017, 8, 9).Contains(new Date(2017, 8, 8), RangeOptions.ExcludeStart);    //false
    new DateRange(2017, 8, 7, 2017, 8, 8).Contains(new Date(2017, 8, 8), RangeOptions.ExcludeEnd);      //false
    new DateRange(2017, 8, 8, 2017, 8, 8).Contains(new Date(2017, 8, 8), RangeOptions.ExcludeStart | RangeOptions.ExcludeEnd);  //false
    new DateRange(2017, 8, 7, 2017, 8, 9).Contains(new Date(2017, 8, 8), RangeOptions.ExcludeStart | RangeOptions.ExcludeEnd);  //true
Parameter Name Description
date date parameter in Date type
options Parameter in the RangeOptions(enum) type ExcludeStart(1), ExcludeEnd(2)

Method: bool Conflicts(DateRange)

Returns true if the DateRange data contains the given range, false otherwise.

Returns true if the start date is equal to the end date of the given date range.

Returns true if the end date is equal to the start date of the given date range.

    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 12)); //true
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 9))); //true
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 9, 2014, 4, 12)); //true
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 9, 2014, 4, 9))); //true
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 8, 2014, 4, 10)); //true

    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 8)); //true
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 10, 2014, 4, 12)); //true

    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 7)); //false
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 11, 2014, 4, 12)); //false
Parameter Name Description
other The object to be compared in the DateRange type

Method: bool Conflicts(DateRange, RangeOptions)

Returns true if the DateRange data contains the given range, false otherwise.

If the options value is specified as ExcludeStart, the start value of the data is considered out of range.

If the options value is specified as ExcludeEnd, the end value of the data is considered out of range.

If both are specified (RangeOptions.ExcludeStart | RangeOptions.ExcludeEnd), start and end dates are considered out of range.

If the options value is not specified and the start date of the data is equal to the end date of the given date range, the method returns true.

If the options value is not specified and the end date of the data is equal to the start date of the given date range, the method returns true.

    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 8), RangeOptions.ExcludeStart); //false
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 8), RangeOptions.ExcludeStart | RangeOptions.ExcludeEnd); //false
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 6, 2014, 4, 8), RangeOptions.ExcludeEnd);  //true

    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 10, 2014, 4, 12), RangeOptions.ExcludeEnd); //false
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 10, 2014, 4, 12), RangeOptions.ExcludeStart | RangeOptions.ExcludeEnd); //false
    new DateRange(2014, 4, 8, 2014, 4, 10).Conflicts(new DateRange(2014, 4, 10, 2014, 4, 12), RangeOptions.ExcludeStart); //true
Parameter Name Description
other he object to be compared in the DateRange type
options Parameter in the RangeOptions(enum) type ExcludeStart(1), ExcludeEnd(2)

Method: int GetDays()

Returns the number of days between the start date and end date of the data.


Method: string ToString()

Returns data in the format yyyyMMdd-yyyyMMdd and in the string type

    new DateRange(2017,8,1,2017,8,7).ToString(); // "20170801-20170807"

Method: bool Equals(Object)

Returns true if the given object has the same value as the DateRange object and the data, false otherwise.

Parameter Name Description
obj Object to be compared

Method: bool Equals(DateRange)

Returns true if the given DateRange object has the same value as the data, false otherwise.

Parameter Name Description
other The object of type DateRange to be compared