Class TimeInterval
Represents a time interval with bounded/unbounded and inclusive/exclusive end points.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public class TimeInterval : Interval<DateTime, TimeSpan, IntervalEndpoint<DateTime>, TimeInterval>, IInterval<DateTime, TimeSpan, IntervalEndpoint<DateTime>, TimeInterval>
Constructors
View SourceTimeInterval(DateTime, DateTime)
Initializes a new instance of the Time
Declaration
public TimeInterval(DateTime leftPoint, DateTime rightPoint)
Parameters
Type | Name | Description |
---|---|---|
Date |
leftPoint | Left bound point. |
Date |
rightPoint | Right bound point. |
Remarks
Defaults to inclusive.
TimeInterval(DateTime, RelativeTimeInterval)
Initializes a new instance of the Time
Declaration
public TimeInterval(DateTime origin, RelativeTimeInterval relative)
Parameters
Type | Name | Description |
---|---|---|
Date |
origin | Origin around which interval is to be created. |
Relative |
relative | Time span interval specifying relative endpoints, bounding and inclusivity. |
TimeInterval(DateTime, Boolean, DateTime, Boolean)
Initializes a new instance of the Time
Declaration
public TimeInterval(DateTime leftPoint, bool leftInclusive, DateTime rightPoint, bool rightInclusive)
Parameters
Type | Name | Description |
---|---|---|
Date |
leftPoint | Left bound point. |
System. |
leftInclusive | Whether left point is inclusive. |
Date |
rightPoint | Right bound point. |
System. |
rightInclusive | Whether right point is inclusive. |
TimeInterval(DateTime, Boolean, Boolean, DateTime, Boolean, Boolean)
Initializes a new instance of the Time
Declaration
public TimeInterval(DateTime leftPoint, bool leftInclusive, bool leftBounded, DateTime rightPoint, bool rightInclusive, bool rightBounded)
Parameters
Type | Name | Description |
---|---|---|
Date |
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. |
Date |
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. |
TimeInterval(IntervalEndpoint<DateTime>, IntervalEndpoint<DateTime>)
Initializes a new instance of the Time
Declaration
public TimeInterval(IntervalEndpoint<DateTime> leftEndpoint, IntervalEndpoint<DateTime> rightEndpoint)
Parameters
Type | Name | Description |
---|---|---|
Interval |
leftEndpoint | Left endpoint. |
Interval |
rightEndpoint | Right endpoint. |
Fields
View SourceEmpty
Canonical empty instance (bounded, non-inclusive, single point).
Declaration
public static readonly TimeInterval Empty
Field Value
Type | Description |
---|---|
Time |
Infinite
Canonical infinite interval (unbounded on both ends).
Declaration
public static readonly TimeInterval Infinite
Field Value
Type | Description |
---|---|
Time |
Properties
View SourcePointMaxValue
Gets the point maximum value.
Declaration
protected override DateTime PointMaxValue { get; }
Property Value
Type | Description |
---|---|
Date |
Overrides
PointMinValue
Gets the point minimum value.
Declaration
protected override DateTime PointMinValue { get; }
Property Value
Type | Description |
---|---|
Date |
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(DateTime, DateTime)
Compare points.
Declaration
protected override int ComparePoints(DateTime a, DateTime b)
Parameters
Type | Name | Description |
---|---|---|
Date |
a | First point. |
Date |
b | Second point. |
Returns
Type | Description |
---|---|
System. |
Less (-1), greater (+1) or equal (0). |
Overrides
Coverage(IEnumerable<TimeInterval>)
Determine coverage from minimum left to maximum right for a set of given intervals.
Declaration
public static TimeInterval Coverage(IEnumerable<TimeInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Time |
intervals | The set of intervals. |
Returns
Type | Description |
---|---|
Time |
Interval from minimum left to maximum right value. |
Remarks
Returns empty interval when sequence is empty or contains only empty intervals.
Difference(DateTime, DateTime)
Determine span between two given points.
Declaration
protected override TimeSpan Difference(DateTime x, DateTime y)
Parameters
Type | Name | Description |
---|---|---|
Date |
x | First point. |
Date |
y | Second point. |
Returns
Type | Description |
---|---|
Time |
Span between points. |
Overrides
Intersect(TimeInterval)
Intersects with a specified time interval.
Declaration
public TimeInterval Intersect(TimeInterval timeInterval)
Parameters
Type | Name | Description |
---|---|---|
Time |
timeInterval | The time interval to intersect with. |
Returns
Type | Description |
---|---|
Time |
The intersection time interval. |
Intersection(IEnumerable<TimeInterval>)
Determine intersection of a specified set of intervals.
Declaration
public static TimeInterval Intersection(IEnumerable<TimeInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Time |
intervals | Set of intervals. |
Returns
Type | Description |
---|---|
Time |
Intersection of the specified set of intervals. |
Remarks
Returns empty when sequence is empty.
LeftBounded(DateTime)
Constructor helper for left-bound instances.
Declaration
public static TimeInterval LeftBounded(DateTime left)
Parameters
Type | Name | Description |
---|---|---|
Date |
left | Left bound point. |
Returns
Type | Description |
---|---|
Time |
A left-bound instance of the Time |
Remarks
Defaults to inclusive.
LeftBounded(DateTime, Boolean)
Constructor helper for left-bound instances.
Declaration
public static TimeInterval LeftBounded(DateTime left, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
Date |
left | Left bound point. |
System. |
inclusive | Whether left point is inclusive. |
Returns
Type | Description |
---|---|
Time |
A left-bound instance of the Time |
Merge(IEnumerable<TimeInterval>)
Merges a specified set of time intervals into a set of non-overlapping time intervals that cover the specified intervals.
Declaration
public static IEnumerable<TimeInterval> Merge(IEnumerable<TimeInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Time |
intervals | A set of time intervals to cover. |
Returns
Type | Description |
---|---|
IEnumerable<Time |
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
RightBounded(DateTime)
Constructor helper for right-bound instances.
Declaration
public static TimeInterval RightBounded(DateTime right)
Parameters
Type | Name | Description |
---|---|---|
Date |
right | Right bound point. |
Returns
Type | Description |
---|---|
Time |
A right-bound instance of the Time |
Remarks
Defaults to inclusive.
RightBounded(DateTime, Boolean)
Constructor helper for right-bound instances.
Declaration
public static TimeInterval RightBounded(DateTime right, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
Date |
right | Right bound point. |
System. |
inclusive | Whether right point is inclusive. |
Returns
Type | Description |
---|---|
Time |
A right-bound instance of the Time |
Scale(Single, Single)
Scale endpoints by factors.
Declaration
public override TimeInterval 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 |
---|---|
Time |
Scaled interval. |
Overrides
Scale(TimeSpan, TimeSpan)
Scale endpoints by span distances.
Declaration
public override TimeInterval 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 |
---|---|
Time |
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
Translate(TimeSpan)
Translate by a span distance.
Declaration
public override TimeInterval Translate(TimeSpan span)
Parameters
Type | Name | Description |
---|---|---|
Time |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
Time |
Translated interval. |
Overrides
Remarks
Unbound points do not change.
TranslatePoint(DateTime, TimeSpan)
Translate point by given span.
Declaration
protected override DateTime TranslatePoint(DateTime point, TimeSpan span)
Parameters
Type | Name | Description |
---|---|---|
Date |
point | Point value. |
Time |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
Date |
Translated point. |