Class RelativeTimeInterval
Represents a TimeSpan interval with bounded/unbounded and inclusive/exclusive end points.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public class RelativeTimeInterval : Interval<TimeSpan, TimeSpan, IntervalEndpoint<TimeSpan>, RelativeTimeInterval>, IInterval<TimeSpan, TimeSpan, IntervalEndpoint<TimeSpan>, RelativeTimeInterval>
Constructors
View SourceRelativeTimeInterval(IntervalEndpoint<TimeSpan>, IntervalEndpoint<TimeSpan>)
Initializes a new instance of the Relative
Declaration
public RelativeTimeInterval(IntervalEndpoint<TimeSpan> leftEndpoint, IntervalEndpoint<TimeSpan> rightEndpoint)
Parameters
Type | Name | Description |
---|---|---|
Interval |
leftEndpoint | Left endpoint. |
Interval |
rightEndpoint | Right endpoint. |
RelativeTimeInterval(TimeSpan, Boolean, Boolean, TimeSpan, Boolean, Boolean)
Initializes a new instance of the Relative
Declaration
public RelativeTimeInterval(TimeSpan leftPoint, bool leftInclusive, bool leftBounded, TimeSpan rightPoint, bool rightInclusive, bool rightBounded)
Parameters
Type | Name | Description |
---|---|---|
Time |
leftPoint | Left bound point (or min value if unbound). |
System. |
leftInclusive | Whether left point is inclusive (always false if unbound). |
System. |
leftBounded | Whether left point is bounded. |
Time |
rightPoint | Right bound point (or min value if unbound). |
System. |
rightInclusive | Whether right point is inclusive (always false if unbound). |
System. |
rightBounded | Whether right point is bounded. |
RelativeTimeInterval(TimeSpan, Boolean, TimeSpan, Boolean)
Initializes a new instance of the Relative
Declaration
public RelativeTimeInterval(TimeSpan leftPoint, bool leftInclusive, TimeSpan rightPoint, bool rightInclusive)
Parameters
Type | Name | Description |
---|---|---|
Time |
leftPoint | Left bound point. |
System. |
leftInclusive | Whether left point is inclusive. |
Time |
rightPoint | Right bound point. |
System. |
rightInclusive | Whether right point is inclusive. |
RelativeTimeInterval(TimeSpan, TimeSpan)
Initializes a new instance of the Relative
Declaration
public RelativeTimeInterval(TimeSpan leftPoint, TimeSpan rightPoint)
Parameters
Type | Name | Description |
---|---|---|
Time |
leftPoint | Left bound point. |
Time |
rightPoint | Right bound point. |
Remarks
Defaults to inclusive.
Fields
View SourceEmpty
Canonical empty instance (bounded, non-inclusive, single point).
Declaration
public static readonly RelativeTimeInterval Empty
Field Value
Type | Description |
---|---|
Relative |
Infinite
Canonical infinite interval (unbounded on both ends).
Declaration
public static readonly RelativeTimeInterval Infinite
Field Value
Type | Description |
---|---|
Relative |
Zero
Zero interval (unbounded but inclusive, zero value).
Declaration
public static readonly RelativeTimeInterval Zero
Field Value
Type | Description |
---|---|
Relative |
Properties
View SourcePointMaxValue
Gets the point maximum value.
Declaration
protected override TimeSpan PointMaxValue { get; }
Property Value
Type | Description |
---|---|
Time |
Overrides
PointMinValue
Gets the point minimum value.
Declaration
protected override TimeSpan PointMinValue { get; }
Property Value
Type | Description |
---|---|
Time |
Overrides
SpanMaxValue
Gets the span maximum value.
Declaration
protected override TimeSpan SpanMaxValue { get; }
Property Value
Type | Description |
---|---|
Time |
Overrides
SpanMinValue
Gets the span minimum value.
Declaration
protected override TimeSpan SpanMinValue { get; }
Property Value
Type | Description |
---|---|
Time |
Overrides
SpanZeroValue
Gets the span zero value.
Declaration
protected override TimeSpan SpanZeroValue { get; }
Property Value
Type | Description |
---|---|
Time |
Overrides
Methods
View SourceComparePoints(TimeSpan, TimeSpan)
Compare points.
Declaration
protected override int ComparePoints(TimeSpan a, TimeSpan b)
Parameters
Type | Name | Description |
---|---|---|
Time |
a | First point. |
Time |
b | Second point. |
Returns
Type | Description |
---|---|
System. |
Less (-1), greater (+1) or equal (0). |
Overrides
Coverage(IEnumerable<RelativeTimeInterval>)
Determine coverage from minimum left to maximum right for a set of given intervals.
Declaration
public static RelativeTimeInterval Coverage(IEnumerable<RelativeTimeInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Relative |
intervals | The set of intervals. |
Returns
Type | Description |
---|---|
Relative |
Interval from minimum left to maximum right value. |
Remarks
Returns empty interval when sequence is empty or contains only empty intervals.
Difference(TimeSpan, TimeSpan)
Determine span between two given points.
Declaration
protected override TimeSpan Difference(TimeSpan x, TimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
Time |
x | First point. |
Time |
y | Second point. |
Returns
Type | Description |
---|---|
Time |
Span between points. |
Overrides
Equals(RelativeTimeInterval)
Declaration
public bool Equals(RelativeTimeInterval other)
Parameters
Type | Name | Description |
---|---|---|
Relative |
other |
Returns
Type | Description |
---|---|
System. |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System. |
obj |
Returns
Type | Description |
---|---|
System. |
Future()
Returns a relative time interval describing the future. The returned interval includes the present moment.
Declaration
public static RelativeTimeInterval Future()
Returns
Type | Description |
---|---|
Relative |
A relative time interval describing the future. |
Future(TimeSpan, Boolean)
Returns a relative time interval of a specified duration in the future. The returned interval includes the present moment.
Declaration
public static RelativeTimeInterval Future(TimeSpan duration, bool inclusive = true)
Parameters
Type | Name | Description |
---|---|---|
Time |
duration | The duration of the time interval. |
System. |
inclusive | Indicates if the interval should be inclusive of the right endpoint. |
Returns
Type | Description |
---|---|
Relative |
A relative time interval of a specified duration in the future. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System. |
LeftBounded(TimeSpan)
Constructor helper for left-bound instances.
Declaration
public static RelativeTimeInterval LeftBounded(TimeSpan left)
Parameters
Type | Name | Description |
---|---|---|
Time |
left | Left bound point. |
Returns
Type | Description |
---|---|
Relative |
A left-bound instance of the Relative |
Remarks
Defaults to inclusive.
LeftBounded(TimeSpan, Boolean)
Constructor helper for left-bound instances.
Declaration
public static RelativeTimeInterval LeftBounded(TimeSpan left, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
Time |
left | Left bound point. |
System. |
inclusive | Whether left point is inclusive. |
Returns
Type | Description |
---|---|
Relative |
A left-bound instance of the Relative |
Merge(IEnumerable<RelativeTimeInterval>)
Merges a specified set of relative time intervals into a set of non-overlapping relative time intervals that cover the specified intervals.
Declaration
public static IEnumerable<RelativeTimeInterval> Merge(IEnumerable<RelativeTimeInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Relative |
intervals | A set of relative time intervals to cover. |
Returns
Type | Description |
---|---|
IEnumerable<Relative |
Set of non-overlapping time intervals that cover the given time intervals. |
NegateSpan(TimeSpan)
Negate span.
Declaration
protected override TimeSpan NegateSpan(TimeSpan span)
Parameters
Type | Name | Description |
---|---|---|
Time |
span | Span to be negated. |
Returns
Type | Description |
---|---|
Time |
Negated span. |
Overrides
Past()
Returns a relative time interval describing the past. The returned interval includes the present moment.
Declaration
public static RelativeTimeInterval Past()
Returns
Type | Description |
---|---|
Relative |
A relative time interval describing the past. |
Past(TimeSpan, Boolean)
Returns a relative time interval of a specified duration in the past. The returned interval includes the present moment.
Declaration
public static RelativeTimeInterval Past(TimeSpan duration, bool inclusive = true)
Parameters
Type | Name | Description |
---|---|---|
Time |
duration | The duration of the time interval. |
System. |
inclusive | Indicates if the interval should be inclusive of the left endpoint. |
Returns
Type | Description |
---|---|
Relative |
A relative time interval of a specified duration in the past. |
RightBounded(TimeSpan)
Constructor helper for right-bound instances.
Declaration
public static RelativeTimeInterval RightBounded(TimeSpan right)
Parameters
Type | Name | Description |
---|---|---|
Time |
right | Right bound point. |
Returns
Type | Description |
---|---|
Relative |
A right-bound instance of the Relative |
Remarks
Defaults to inclusive.
RightBounded(TimeSpan, Boolean)
Constructor helper for right-bound instances.
Declaration
public static RelativeTimeInterval RightBounded(TimeSpan right, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
Time |
right | Right bound point. |
System. |
inclusive | Whether right point is inclusive. |
Returns
Type | Description |
---|---|
Relative |
A right-bound instance of the Relative |
Scale(Single, Single)
Scale endpoints by factors.
Declaration
public override RelativeTimeInterval Scale(float left, float right)
Parameters
Type | Name | Description |
---|---|---|
System. |
left | Factor by which to scale left. |
System. |
right | Factor by which to scale right. |
Returns
Type | Description |
---|---|
Relative |
Scaled interval. |
Overrides
Scale(TimeSpan, TimeSpan)
Scale endpoints by span distances.
Declaration
public override RelativeTimeInterval Scale(TimeSpan left, TimeSpan right)
Parameters
Type | Name | Description |
---|---|---|
Time |
left | Span by which to scale left. |
Time |
right | Span by which to scale right. |
Returns
Type | Description |
---|---|
Relative |
Scaled interval. |
Overrides
ScaleSpan(TimeSpan, Double)
Scale a span by a given factor.
Declaration
protected override TimeSpan ScaleSpan(TimeSpan span, double factor)
Parameters
Type | Name | Description |
---|---|---|
Time |
span | Span value. |
System. |
factor | Factor by which to scale. |
Returns
Type | Description |
---|---|
Time |
Scaled span. |
Overrides
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System. |
Translate(TimeSpan)
Translate by a span distance.
Declaration
public override RelativeTimeInterval Translate(TimeSpan span)
Parameters
Type | Name | Description |
---|---|---|
Time |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
Relative |
Translated interval. |
Overrides
Remarks
Unbound points do not change.
TranslatePoint(TimeSpan, TimeSpan)
Translate point by given span.
Declaration
protected override TimeSpan TranslatePoint(TimeSpan point, TimeSpan span)
Parameters
Type | Name | Description |
---|---|---|
Time |
point | Point value. |
Time |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
Time |
Translated point. |
Overrides
Operators
View SourceAddition(DateTime, RelativeTimeInterval)
Construct TimeInterval relative to an origin (DateTime).
Declaration
public static TimeInterval operator +(DateTime origin, RelativeTimeInterval relative)
Parameters
Type | Name | Description |
---|---|---|
Date |
origin | Origin time point. |
Relative |
relative | Relative endpoints. |
Returns
Type | Description |
---|---|
Time |
Translated interval. |
Equality(RelativeTimeInterval, RelativeTimeInterval)
Equality operator that returns true if the operands are equal, false otherwise.
Declaration
public static bool operator ==(RelativeTimeInterval x, RelativeTimeInterval y)
Parameters
Type | Name | Description |
---|---|---|
Relative |
x | The first operand. |
Relative |
y | The second operand. |
Returns
Type | Description |
---|---|
System. |
A value indicating whether the operands are equal. |
Inequality(RelativeTimeInterval, RelativeTimeInterval)
Inequality operator that returns true if the operands are not equal, false otherwise.
Declaration
public static bool operator !=(RelativeTimeInterval x, RelativeTimeInterval y)
Parameters
Type | Name | Description |
---|---|---|
Relative |
x | The first operand. |
Relative |
y | The second operand. |
Returns
Type | Description |
---|---|
System. |
A value indicating whether the operands are not equal. |