Struct Duration
Represents a duration. A duration stores separately months, days, and seconds due to the fact that the
number of days in a month varies, and a day can have 23 or 25 hours if a daylight saving is involved.
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Dse
Assembly: Dse.dll
Syntax
public struct Duration : IEquatable<Duration>, IComparable<Duration>
Constructors
Duration(Int32, Int32, Int64)
Declaration
public Duration(int months, int days, long nanoseconds)
Parameters
Type |
Name |
Description |
System.Int32 |
months |
The number of months.
|
System.Int32 |
days |
The number of days.
|
System.Int64 |
nanoseconds |
The number of nanoseconds.
|
Fields
Zero
Declaration
public static readonly Duration Zero
Field Value
Properties
Days
Declaration
Property Value
Type |
Description |
System.Int32 |
|
Months
Gets the number of months.
Declaration
public int Months { get; }
Property Value
Type |
Description |
System.Int32 |
|
Nanoseconds
Gets the number of nanoseconds.
Declaration
public long Nanoseconds { get; }
Property Value
Type |
Description |
System.Int64 |
|
Methods
CompareTo(Duration)
Compares this instance against another Duration instance based on the bytes representation
of the values.
Declaration
public int CompareTo(Duration other)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Equals(Duration)
Returns true if the value of the Duration is the same.
Declaration
public bool Equals(Duration other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Returns true if the value of the Duration is the same.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
FromTimeSpan(TimeSpan)
Creates a new Duration instance based on the System.TimeSpan provided.
Consider that 24 hour days (no leap seconds) are used to calculate the days portion.
Declaration
public static Duration FromTimeSpan(TimeSpan timespan)
Parameters
Type |
Name |
Description |
System.TimeSpan |
timespan |
|
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
Parse(String)
Creates a new Duration instance from the string representation of the value.
Accepted formats:
Declaration
public static Duration Parse(string input)
Parameters
Type |
Name |
Description |
System.String |
input |
|
Returns
ToIsoString()
A string representation of this duration using ISO-8601 based representation, such as PT8H6M12.345S.
Declaration
public string ToIsoString()
Returns
Type |
Description |
System.String |
|
ToString()
Returns the string representation of the value.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()
ToTimeSpan()
Returns a System.TimeSpan instance that represents the same interval than this instance.
You should take into consideration that System.TimeSpan is internally represented in ticks,
so for the conversion, 24h days will be used (leap seconds are not considered).
For Duration values with month portion, it will throw an
System.InvalidOperationException.
Declaration
public TimeSpan ToTimeSpan()
Returns
Type |
Description |
System.TimeSpan |
|
Exceptions
Type |
Condition |
System.InvalidOperationException |
values including month portion.
|
Operators
Equality(Duration, Duration)
Compares value equality of 2 DateRange instances.
Declaration
public static bool operator ==(Duration a, Duration b)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Inequality(Duration, Duration)
Compares value inequality of 2 DateRange instances.
Declaration
public static bool operator !=(Duration a, Duration b)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implements
System.IEquatable<T>
System.IComparable<T>