Struct Interval
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[Serializable]
public struct Interval : IEquatable<Interval>, IXmlSerializable, ISerializable
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Constructors
Interval(Instant, Instant)
start
instant and excludes the
end
instant. The end may equal the start (resulting in an empty interval), but must not be before the start.
Declaration
public Interval(Instant start, Instant end)
Parameters
Type | Name | Description |
---|---|---|
Instant | start | The start Instant. |
Instant | end | The end Instant. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | end is earlier than start . |
Interval(Nullable<Instant>, Nullable<Instant>)
Declaration
public Interval(Instant? start, Instant? end)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Instant> | start | The start Instant or null. |
Nullable<Instant> | end | The end Instant or null. |
Remarks
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | end is earlier than start ,
if they are both non-null. |
Properties
Duration
Declaration
public Duration Duration { get; }
Property Value
Type | Description |
---|---|
Duration | The duration of the interval. |
Remarks
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The interval extends to the start or end of time. |
End
Declaration
public Instant End { get; }
Property Value
Type | Description |
---|---|
Instant | The end Instant. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The interval extends to the end of time. |
See Also
HasEnd
true
if this interval has a fixed end point, or false
if it
extends to the end of time.
Declaration
public bool HasEnd { get; }
Property Value
Type | Description |
---|---|
Boolean | true if this interval has a fixed end point, or false if it
extends to the end of time. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
HasStart
true
if this interval has a fixed start point, or false
if it
extends to the start of time.
Declaration
public bool HasStart { get; }
Property Value
Type | Description |
---|---|
Boolean | true if this interval has a fixed start point, or false if it
extends to the start of time. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Start
Declaration
public Instant Start { get; }
Property Value
Type | Description |
---|---|
Instant | The start Instant. |
Remarks
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The interval extends to the start of time. |
See Also
Methods
Contains(Instant)
Declaration
public bool Contains(Instant instant)
Parameters
Type | Name | Description |
---|---|---|
Instant | instant | Instant to test. |
Returns
Type | Description |
---|---|
Boolean | True if this interval contains the given instant; false otherwise. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Deconstruct(out Nullable<Instant>, out Nullable<Instant>)
Declaration
public void Deconstruct(out Instant? start, out Instant? end)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Instant> | start | The start of the interval. |
Nullable<Instant> | end | The end of the interval. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Equals(Interval)
Declaration
public bool Equals(Interval other)
Parameters
Type | Name | Description |
---|---|---|
Interval | other | The value to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean |
true if the value of this instant is equal to the value of the other parameter;
otherwise, false.
|
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The Object to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean |
true if the specified Object is equal to this instance;
otherwise, false .
|
Overrides
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string representation of this interval. |
Overrides
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Operators
Equality(Interval, Interval)
Declaration
public static bool operator ==(Interval left, Interval right)
Parameters
Type | Name | Description |
---|---|---|
Interval | left | The left. |
Interval | right | The right. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Inequality(Interval, Interval)
Declaration
public static bool operator !=(Interval left, Interval right)
Parameters
Type | Name | Description |
---|---|---|
Interval | left | The left. |
Interval | right | The right. |
Returns
Type | Description |
---|---|
Boolean | The result of the operator. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Explicit Interface Implementations
ISerializable.GetObjectData(SerializationInfo, StreamingContext)
Declaration
[SecurityCritical]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | The SerializationInfo to populate with data. |
StreamingContext | context | The destination for this serialization. |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | info is null. |
IXmlSerializable.GetSchema()
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type | Description |
---|---|
XmlSchema |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
IXmlSerializable.ReadXml(XmlReader)
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | reader |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | reader is null. |
IXmlSerializable.WriteXml(XmlWriter)
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
XmlWriter | writer |
Remarks
The interval includes the start instant and excludes the end instant. However, an interval may be missing its start or end, in which case the interval is deemed to be infinite in that direction.
The end may equal the start (resulting in an empty interval), but will not be before the start.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | writer is null. |