Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct NodaTime.​HighPerformance.​Duration64

Assembly: NodaTime

Implemented Interfaces

Represents a fixed (and calendar-independent) length of time. This type is a equivalent to <see cref="T:NodaTime.Duration" /> , but with a more limited range (a few hundred years) and more compact, high performance representation. It is expected to be used in conjunction with <see cref="T:NodaTime.HighPerformance.Instant64" /> , typically in scenarios where performance and/or memory usage are important. Note that in most cases, <see cref="T:NodaTime.Duration" /> is more appropriate and convenient (with more supported methods etc). This should effectively be regarded as a specialist type for unusually performance-sensitive scenarios.

Remarks

<para> A duration is a length of time defined by an integral number of nanoseconds. Although durations are usually used with a positive number of nanoseconds, negative durations are valid, and may occur naturally when e.g. subtracting a later <see cref="T:NodaTime.HighPerformance.Instant64" /> from an earlier one. </para> <para>Equality and ordering are defined in the natural way, simply comparing the number of nanoseconds contained.</para> <para>The default value of this type is <see cref="P:NodaTime.HighPerformance.Duration64.Zero" />.</para>

Properties

public static Duration64
Zero
Gets a zero <see cref="T:NodaTime.HighPerformance.Duration64" /> of 0 nanoseconds.
public static Duration64
AdditiveIdentity
Gets the additive identity.
public static Duration64
Epsilon
Gets a <see cref="T:NodaTime.HighPerformance.Duration64" /> value equal to 1 nanosecond; the smallest amount by which an instant can vary.
public static Duration64
MaxValue
Gets the maximum value supported by <see cref="T:NodaTime.HighPerformance.Duration64" /> . This is around 292 years.
public static Duration64
MinValue
Gets the minimum (largest negative) value supported by <see cref="T:NodaTime.HighPerformance.Duration64" /> . This is around -292 years.
public long
TotalNanoseconds
Gets the total number of nanoseconds in this duration, as an <see cref="T:System.Int64" /> .

Methods

public bool
Equals​(object obj)
Determines whether the specified <see cref="T:System.Object" /> is equal to this instance. See the type documentation for a description of equality semantics.
Returns <c>true</c> if the specified <see cref="T:System.Object" /> is equal to this instance; otherwise, <c>false</c> .
obj The <see cref="T:System.Object" /> to compare with this instance.
public int
GetHashCode​()
Returns a hash code for this instance. See the type documentation for a description of equality semantics.
Returns A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
public string
ToString​()
Returns a <see cref="T:System.String" /> that represents this instance.
Returns The value of the current instance, converted to a <see cref="T:NodaTime.Duration" /> , in the default format pattern ("o"), using the current thread's culture to obtain a format provider.
public string
ToString​(string patternText, System.​IFormatProvider formatProvider)
Formats the value of the current instance using the specified pattern.
Returns A <see cref="T:System.String" /> containing the value of the current instance, converted to a <see cref="T:NodaTime.Duration" /> in the specified format.
patternText The <see cref="T:System.String" /> specifying the pattern to use, or null to use the default format pattern ("o").
formatProvider The <see cref="T:System.IFormatProvider" /> to use when formatting the value, or null to use the current thread's culture to obtain a format provider.
public static Duration64
Add​(Duration64 left, Duration64 right)
Adds one duration to another. Friendly alternative to <c>operator+()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the sum of the given values.
left The left hand side of the operator.
right The right hand side of the operator.
public Duration64
Plus​(Duration64 other)
Returns the result of adding another duration to this one, for a fluent alternative to <c>operator+()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the result of the addition.
other The duration to add
public static Duration64
Subtract​(Duration64 left, Duration64 right)
Subtracts one duration from another. Friendly alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the difference of the given values.
left The left hand side of the operator.
right The right hand side of the operator.
public Duration64
Minus​(Duration64 other)
Returns the result of subtracting another duration from this one, for a fluent alternative to <c>operator-()</c> .
Returns A new <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the result of the subtraction.
other The duration to subtract
public static Duration64
Negate​(Duration64 duration)
Implements a friendly alternative to the unary negation operator.
Returns The negative value of this duration
duration Duration64 to negate
public int
CompareTo​(Duration64 other)
Implementation of <see cref="M:System.IComparable`1.CompareTo(`0)" /> to compare two durations. See the type documentation for a description of ordering semantics.
Returns A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: <list type="table"> <listheader> <term>Value</term> <description>Meaning</description> </listheader> <item> <term>&lt; 0</term> <description>This object is less than the <paramref name="other" /> parameter.</description> </item> <item> <term>0</term> <description>This object is equal to <paramref name="other" />.</description> </item> <item> <term>&gt; 0</term> <description>This object is greater than <paramref name="other" />.</description> </item> </list>
other An object to compare with this object.
public bool
Equals​(Duration64 other)
Indicates whether the current object is equal to another object of the same type. See the type documentation for a description of equality semantics.
Returns true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
other An object to compare with this object.
public static Duration64
FromTimeSpan​(System.​TimeSpan timeSpan)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the same number of ticks as the given <see cref="T:System.TimeSpan" /> .
Returns A new Duration64 with the same number of ticks as the given TimeSpan.
timeSpan The TimeSpan value to convert
ToTimeSpan​()
Returns a <see cref="T:System.TimeSpan" /> that represents the same number of ticks as this <see cref="T:NodaTime.HighPerformance.Duration64" /> .
Returns A new TimeSpan with the same number of ticks as this Duration.
Remarks If the number of nanoseconds in a duration is not a whole number of ticks, it is truncated towards zero. For example, durations in the range [-99ns, 99ns] would all count as 0 ticks.
public static Duration64
FromDays​(int days)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of days, assuming a 'standard' 24-hour day.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of days.
days The number of days.
public static Duration64
FromHours​(int hours)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of hours.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of hours.
hours The number of hours.
public static Duration64
FromMinutes​(long minutes)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of minutes.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of minutes.
minutes The number of minutes.
public static Duration64
FromSeconds​(long seconds)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of seconds.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of seconds.
seconds The number of seconds.
public static Duration64
FromMilliseconds​(long milliseconds)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of milliseconds.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of milliseconds.
milliseconds The number of milliseconds.
public static Duration64
FromTicks​(long ticks)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of ticks.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of ticks.
ticks The number of ticks.
public static Duration64
FromNanoseconds​(long nanoseconds)
Returns a <see cref="T:NodaTime.HighPerformance.Duration64" /> that represents the given number of nanoseconds.
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> representing the given number of nanoseconds.
nanoseconds The number of nanoseconds.
public static Duration64
Max​(Duration64 x, Duration64 y)
Returns the larger duration of the given two.
Returns The larger duration of <paramref name="x" /> or <paramref name="y" /> .
x The first duration to compare.
y The second duration to compare.
Remarks A "larger" duration is one that advances time by more than a "smaller" one. This means that a positive duration is always larger than a negative one, for example. (This is the same comparison used by the binary comparison operators.)
public static Duration64
Min​(Duration64 x, Duration64 y)
Returns the smaller duration of the given two.
Returns The smaller duration of <paramref name="x" /> or <paramref name="y" /> .
x The first duration to compare.
y The second duration to compare.
Remarks A "larger" duration is one that advances time by more than a "smaller" one. This means that a positive duration is always larger than a negative one, for example. (This is the same comparison used by the binary comparison operators.)
public Duration
ToDuration​()
Converts this value to a <see cref="T:NodaTime.Duration" /> representing the same number of nanoseconds. This operation always succeeds and loses no information.
Returns A <see cref="T:NodaTime.Duration" /> representing the same number of nanoseconds as this one.
public static Duration64
FromDuration​(Duration duration)
Creates a <see cref="T:NodaTime.HighPerformance.Duration64" /> value representing the same number of nanoseconds as the specified <see cref="T:NodaTime.Duration" /> . When this succeeds, this conversion loses no information. If the specified value is outside the range of <see cref="T:NodaTime.HighPerformance.Duration64" /> , this method will fail with an <see cref="T:System.OverflowException" /> .
Returns A <see cref="T:NodaTime.HighPerformance.Duration64" /> value equivalent to <paramref name="duration" /> .
duration The value to convert to a <see cref="T:NodaTime.HighPerformance.Duration64" /> .
protected void
Finalize​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object