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.
Assembly: Cassandra.dll
Syntax
public struct Duration : IEquatable<Duration>, IComparable<Duration>
Remarks
Constructors
Duration(int, int, long)
Declaration
public Duration(int months, int days, long nanoseconds)
Parameters
Type |
Name |
Description |
int |
months |
The number of months.
|
int |
days |
The number of days.
|
long |
nanoseconds |
The number of nanoseconds.
|
Fields
Zero
Declaration
public static readonly Duration Zero
Field Value
Properties
Days
Declaration
Property Value
Months
Gets the number of months.
Declaration
public int Months { get; }
Property Value
Nanoseconds
Gets the number of nanoseconds.
Declaration
public long Nanoseconds { get; }
Property Value
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
Equals(Duration)
Returns true if the value of the Duration is the same.
Declaration
public bool Equals(Duration other)
Parameters
Returns
Equals(object)
Returns true if the value of the Duration is the same.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
Overrides
FromTimeSpan(TimeSpan)
Creates a new Duration instance based on the 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
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
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 |
string |
input |
|
Returns
ToIsoString()
A string representation of this duration using ISO-8601 based representation, such as PT8H6M12.345S.
Declaration
public string ToIsoString()
Returns
ToString()
Returns the string representation of the value.
Declaration
public override string ToString()
Returns
Overrides
ToTimeSpan()
Returns a TimeSpan instance that represents the same interval than this instance.
You should take into consideration that 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
InvalidOperationException.
Declaration
public TimeSpan ToTimeSpan()
Returns
Exceptions
Operators
operator ==(Duration, Duration)
Compares value equality of 2 DateRange instances.
Declaration
public static bool operator ==(Duration a, Duration b)
Parameters
Returns
explicit operator Duration(TimeSpan)
Declaration
public static explicit operator Duration(TimeSpan ts)
Parameters
Returns
operator !=(Duration, Duration)
Compares value inequality of 2 DateRange instances.
Declaration
public static bool operator !=(Duration a, Duration b)
Parameters
Returns
Implements