Click or drag to resize
Duration Structure
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.

Namespace: Dse
Assembly: Dse (in Dse.dll) Version: 2.1.0
Syntax
C#
public struct Duration : IEquatable<Duration>, 
	IComparable<Duration>

The Duration type exposes the following members.

Constructors
  NameDescription
Public methodDuration
Creates a new instance of Duration.
Top
Methods
  NameDescription
Public methodCompareTo
Compares this instance against another Duration instance based on the bytes representation of the values.
Public methodEquals(Object)
Returns true if the value of the Duration is the same.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(Duration)
Returns true if the value of the Duration is the same.
Public methodStatic memberFromTimeSpan
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.

Public methodGetHashCode
Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberParse
Creates a new Duration instance from the string representation of the value.

Accepted formats:

  • multiple digits followed by a time unit like: 12h30m where the time unit can be:
    • y: years
    • m: months
    • w: weeks
    • d: days
    • h: hours
    • m: minutes
    • s: seconds
    • ms: milliseconds
    • us or µs: microseconds
    • ns: nanoseconds
  • ISO 8601 format:
    P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W
  • ISO 8601 alternative format:
    P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]
Public methodToIsoString
A string representation of this duration using ISO-8601 based representation, such as PT8H6M12.345S.
Public methodToString
Returns the string representation of the value.
(Overrides ValueTypeToString.)
Public methodToTimeSpan
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.

Top
Operators
  NameDescription
Public operatorStatic memberEquality
Compares value equality of 2 DateRange instances.
Public operatorStatic memberInequality
Compares value inequality of 2 DateRange instances.
Top
Fields
  NameDescription
Public fieldStatic memberZero
Top
Properties
  NameDescription
Public propertyDays
Gets the number of days.
Public propertyMonths
Gets the number of months.
Public propertyNanoseconds
Gets the number of nanoseconds.
Top
Remarks
Duration instances are immutable and thread-safe.
See Also

Reference