Click or drag to resize

DayRangePeriodWithMinimumDayRange Method

Returns a new DayRangePeriod with the same DayRange as this, but also specifying minimumDayRange as the minimum range required.

Namespace: DegreeDays.Api.Data.Impl
Assembly: DegreeDays (in DegreeDays.dll) Version: 1.4
Syntax
public DayRangePeriod WithMinimumDayRange(
	DayRange minimumDayRange
)

Parameters

minimumDayRange  DayRange
The minimum range that the returned DayRangePeriod object should hold.

Return Value

DayRangePeriod
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionminimumDayRange extends earlier or later than DayRange.
Remarks

By default a DayRangePeriod does not have a minimum range. Without a minimum range, the API can decide what to do if there is not enough data available to satisfy the DayRange, and it will typically return what it can from within DayRange. If this method is used to specify a minimum range, then a request for data will fail unless that minimum range can be satisfied.

The following example shows typical usage of this method:

DayRangePeriod period = 
    Period.DayRange(targetRange).WithMinimumDayRange(minimumRange);

Warning: be careful with minimum ranges, particularly when defining the last day of a minimum range. The degree days for any given day will never become available until the day has finished in the location's local time-zone, and will always take at least at least a little longer (and sometimes quite a lot longer) for the reasons explained here. If your system specifies a minimum range that is too restrictive, it can easily end up with no data at all when in fact there's plenty of usable data available.

That said, there are times when a minimum range with highly-restrictive dates is exactly what you want (and you'd rather get nothing than slightly less data), so don't be afraid to specify restrictive minimum ranges if you need them.

See Also