Struct Duration
Implements
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[Serializable]
public struct Duration : IEquatable<Duration>, IComparable<Duration>, IComparable, IXmlSerializable, IFormattable, ISerializable
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Properties
BclCompatibleTicks
Declaration
public long BclCompatibleTicks { get; }
Property Value
Type  Description 

Int64  The total number of ticks in the duration. 
Remarks
Within the constraints specified below, this property is intended to be equivalent to Ticks.
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.
Although this method can overflow, it will only do so in very exceptional cases, with durations with a magnitude of more than 29000 Gregorian years or so.
Exceptions
Type  Condition 

OverflowException  The number of ticks cannot be represented a signed 64bit integer. 
See Also
Days
Declaration
public int Days { get; }
Property Value
Type  Description 

Int32  The whole number of days in the duration 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Epsilon
Declaration
public static Duration Epsilon { get; }
Property Value
Type  Description 

Duration  A duration representing 1 nanosecond. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Hours
Declaration
public int Hours { get; }
Property Value
Type  Description 

Int32  The hour component of the duration, within the day. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
MaxValue
Declaration
public static Duration MaxValue { get; }
Property Value
Type  Description 

Duration 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Milliseconds
Declaration
public int Milliseconds { get; }
Property Value
Type  Description 

Int32  The subsecond component of the duration, in milliseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Minutes
Declaration
public int Minutes { get; }
Property Value
Type  Description 

Int32  The minute component of the duration, within the hour. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
MinValue
Declaration
public static Duration MinValue { get; }
Property Value
Type  Description 

Duration 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
NanosecondOfDay
Declaration
public long NanosecondOfDay { get; }
Property Value
Type  Description 

Int64  The number of nanoseconds within the day of this duration. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Seconds
Declaration
public int Seconds { get; }
Property Value
Type  Description 

Int32  The second component of the duration, within the minute. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
SubsecondNanoseconds
Declaration
public int SubsecondNanoseconds { get; }
Property Value
Type  Description 

Int32  The subsecond component of the duration, in nanoseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
SubsecondTicks
Declaration
public int SubsecondTicks { get; }
Property Value
Type  Description 

Int32  The subsecond component of the duration, in ticks. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
TotalDays
Declaration
public double TotalDays { get; }
Property Value
Type  Description 

Double  The total number of days in this duration. 
Remarks
Duration
equivalent of TotalDays.
It represents the complete duration in days, rather than only the whole number of
days. For example, for a duration of 36 hours, this property would return 1.5.
TotalHours
Declaration
public double TotalHours { get; }
Property Value
Type  Description 

Double  The total number of hours in this duration. 
Remarks
Duration
equivalent of TotalHours.
Unlike Hours, it represents the complete duration in hours rather than the
whole number of hours as part of the day. So for a duration
of 1 day, 2 hours and 30 minutes, the Hours
property will return 2, but TotalHours
will return 26.5.
TotalMilliseconds
Declaration
public double TotalMilliseconds { get; }
Property Value
Type  Description 

Double  The total number of milliseconds in this duration. 
Remarks
Duration
equivalent of TotalMilliseconds.
Unlike Milliseconds, it represents the complete duration in seconds rather than
the whole number of seconds within the minute. So for a duration
of 10 minutes, 20 seconds and 250 milliseconds, the Seconds
property will return 20, but TotalSeconds
will return 620.25.
TotalMinutes
Declaration
public double TotalMinutes { get; }
Property Value
Type  Description 

Double  The total number of minutes in this duration. 
Remarks
Duration
equivalent of TotalMinutes.
Unlike Minutes, it represents the complete duration in minutes rather than
the whole number of minutes within the hour. So for a duration
of 2 hours, 30 minutes and 45 seconds, the Minutes
property will return 30, but TotalMinutes
will return 150.75.
TotalNanoseconds
Declaration
public double TotalNanoseconds { get; }
Property Value
Type  Description 

Double  This duration as a number of nanoseconds, represented as a Double . 
Remarks
Double
type. In other works, Duration.FromNanoseconds(duration.TotalNanoseconds)
is not guaranteed to roundtrip. To guarantee precision and roundtripping,
use ToBigIntegerNanoseconds() and FromNanoseconds(BigInteger).
TotalSeconds
Declaration
public double TotalSeconds { get; }
Property Value
Type  Description 

Double  The total number of seconds in this duration. 
Remarks
Duration
equivalent of TotalSeconds.
Unlike Seconds, it represents the complete duration in seconds rather than
the whole number of seconds within the minute. So for a duration
of 10 minutes, 20 seconds and 250 milliseconds, the Seconds
property will return 20, but TotalSeconds
will return 620.25.
TotalTicks
Declaration
public double TotalTicks { get; }
Property Value
Type  Description 

Double  The total number of ticks in this duration. 
Remarks
Duration
equivalent of Ticks,
except represented as doubleprecision floating point number instead of a 64bit integer. This
is because Duration has a precision of nanoseconds, and also because the range
of 64bit integers doesn't cover the number of possible ticks in a Duration. (The
latter is only an issue in durations outside the range of TimeSpan  in other words,
with magnitudes of over 29,000 years.)
See Also
Zero
Declaration
public static Duration Zero { get; }
Property Value
Type  Description 

Duration  The zero Duration value. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Methods
Add(Duration, Duration)
operator+()
.
Declaration
public static Duration Add(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the sum of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
CompareTo(Duration)
Declaration
public int CompareTo(Duration other)
Parameters
Type  Name  Description 

Duration  other  An object to compare with this object. 
Returns
Type  Description  

Int32 
A 32bit signed integer that indicates the relative order of the objects being compared.
The return value has the following meanings:

Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Divide(Duration, Duration)
operator/()
.
Declaration
public static double Divide(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Double  The Double representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Divide(Duration, Double)
operator/()
.
Declaration
public static Duration Divide(Duration left, double right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Double  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Divide(Duration, Int64)
operator/()
.
Declaration
public static Duration Divide(Duration left, long right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Int64  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Equals(Duration)
Declaration
public bool Equals(Duration other)
Parameters
Type  Name  Description 

Duration  other  An object to compare with this object. 
Returns
Type  Description 

Boolean 
true if the current object is equal to the other parameter;
otherwise, false.

Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
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
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromDays(Double)
Declaration
public static Duration FromDays(double days)
Parameters
Type  Name  Description 

Double  days  The number of days. 
Returns
Type  Description 

Duration  A Duration representing the given number of days. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromDays(Int32)
Declaration
public static Duration FromDays(int days)
Parameters
Type  Name  Description 

Int32  days  The number of days. 
Returns
Type  Description 

Duration  A Duration representing the given number of days. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromDays(5);
Console.WriteLine(duration.Days);
Console.WriteLine(duration.ToString());
Output:
5
5:00:00:00
FromHours(Double)
Declaration
public static Duration FromHours(double hours)
Parameters
Type  Name  Description 

Double  hours  The number of hours. 
Returns
Type  Description 

Duration  A Duration representing the given number of hours. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromHours(1.5);
Console.WriteLine(duration.Hours);
Console.WriteLine(duration.TotalHours);
Console.WriteLine(duration.TotalMinutes);
Console.WriteLine(duration.ToString());
Output:
1
1.5
90
0:01:30:00
FromHours(Int32)
Declaration
public static Duration FromHours(int hours)
Parameters
Type  Name  Description 

Int32  hours  The number of hours. 
Returns
Type  Description 

Duration  A Duration representing the given number of hours. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromMilliseconds(Double)
Declaration
public static Duration FromMilliseconds(double milliseconds)
Parameters
Type  Name  Description 

Double  milliseconds  The number of milliseconds. 
Returns
Type  Description 

Duration  A Duration representing the given number of milliseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromMilliseconds(Int64)
Declaration
public static Duration FromMilliseconds(long milliseconds)
Parameters
Type  Name  Description 

Int64  milliseconds  The number of milliseconds. 
Returns
Type  Description 

Duration  A Duration representing the given number of milliseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromMilliseconds(600);
Console.WriteLine(duration.Milliseconds);
Console.WriteLine(duration.TotalSeconds);
Console.WriteLine(duration.ToString());
Output:
600
0.6
0:00:00:00.6
FromMinutes(Double)
Declaration
public static Duration FromMinutes(double minutes)
Parameters
Type  Name  Description 

Double  minutes  The number of minutes. 
Returns
Type  Description 

Duration  A Duration representing the given number of minutes. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromMinutes(Int64)
Declaration
public static Duration FromMinutes(long minutes)
Parameters
Type  Name  Description 

Int64  minutes  The number of minutes. 
Returns
Type  Description 

Duration  A Duration representing the given number of minutes. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromMinutes(50);
Console.WriteLine(duration.Minutes);
Console.WriteLine(duration.ToString());
Output:
50
0:00:50:00
FromNanoseconds(Double)
Declaration
public static Duration FromNanoseconds(double nanoseconds)
Parameters
Type  Name  Description 

Double  nanoseconds  The number of nanoseconds to represent. 
Returns
Type  Description 

Duration  A duration with the given number of nanoseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromNanoseconds(Int64)
Declaration
public static Duration FromNanoseconds(long nanoseconds)
Parameters
Type  Name  Description 

Int64  nanoseconds  The number of nanoseconds. 
Returns
Type  Description 

Duration  A Duration representing the given number of nanoseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromNanoseconds(1_000_000_000);
Console.WriteLine(duration.TotalNanoseconds);
Console.WriteLine(duration.TotalSeconds);
Console.WriteLine(duration.ToString());
Output:
1000000000
1
0:00:00:01
FromNanoseconds(BigInteger)
Declaration
public static Duration FromNanoseconds(BigInteger nanoseconds)
Parameters
Type  Name  Description 

BigInteger  nanoseconds  The number of nanoseconds to represent. 
Returns
Type  Description 

Duration  A duration with the given number of nanoseconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromSeconds(Double)
Declaration
public static Duration FromSeconds(double seconds)
Parameters
Type  Name  Description 

Double  seconds  The number of seconds. 
Returns
Type  Description 

Duration  A Duration representing the given number of seconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromSeconds(Int64)
Declaration
public static Duration FromSeconds(long seconds)
Parameters
Type  Name  Description 

Int64  seconds  The number of seconds. 
Returns
Type  Description 

Duration  A Duration representing the given number of seconds. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromSeconds(42);
Console.WriteLine(duration.Seconds);
Console.WriteLine(duration.ToString());
Output:
42
0:00:00:42
FromTicks(Double)
Declaration
public static Duration FromTicks(double ticks)
Parameters
Type  Name  Description 

Double  ticks  The number of ticks. 
Returns
Type  Description 

Duration  A Duration representing the given number of ticks. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
FromTicks(Int64)
Declaration
public static Duration FromTicks(long ticks)
Parameters
Type  Name  Description 

Int64  ticks  The number of ticks. 
Returns
Type  Description 

Duration  A Duration representing the given number of ticks. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromTicks(10_000_000);
Console.WriteLine(duration.TotalTicks);
Console.WriteLine(duration.TotalSeconds);
Console.WriteLine(duration.ToString());
Output:
10000000
1
0:00:00:01
FromTimeSpan(TimeSpan)
Declaration
public static Duration FromTimeSpan(TimeSpan timeSpan)
Parameters
Type  Name  Description 

TimeSpan  timeSpan  The TimeSpan value to convert 
Returns
Type  Description 

Duration  A new Duration with the same number of ticks as the given TimeSpan. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Sample snippet
using NodaTime;
using System;
Duration duration = Duration.FromTimeSpan(TimeSpan.FromHours(3));
Console.WriteLine(duration.Hours);
Console.WriteLine(duration.ToString());
Output:
3
0:03:00:00
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type  Description 

Int32  A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
Overrides
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Max(Duration, Duration)
Declaration
public static Duration Max(Duration x, Duration y)
Parameters
Type  Name  Description 

Duration  x  The first duration to compare. 
Duration  y  The second duration to compare. 
Returns
Type  Description 

Duration  The larger duration of x or y . 
Remarks
Min(Duration, Duration)
Declaration
public static Duration Min(Duration x, Duration y)
Parameters
Type  Name  Description 

Duration  x  The first duration to compare. 
Duration  y  The second duration to compare. 
Returns
Type  Description 

Duration  The smaller duration of x or y . 
Remarks
Minus(Duration)
operator()
.
Declaration
public Duration Minus(Duration other)
Parameters
Type  Name  Description 

Duration  other  The duration to subtract 
Returns
Type  Description 

Duration  A new Duration representing the result of the subtraction. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Duration, Double)
operator*()
.
Declaration
public static Duration Multiply(Duration left, double right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Double  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the product of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Duration, Int64)
operator*()
.
Declaration
public static Duration Multiply(Duration left, long right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Int64  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the product of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Int64, Duration)
operator*()
.
Declaration
public static Duration Multiply(long left, Duration right)
Parameters
Type  Name  Description 

Int64  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the product of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Negate(Duration)
Declaration
public static Duration Negate(Duration duration)
Parameters
Type  Name  Description 

Duration  duration  Duration to negate 
Returns
Type  Description 

Duration  The negative value of this duration 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Plus(Duration)
operator+()
.
Declaration
public Duration Plus(Duration other)
Parameters
Type  Name  Description 

Duration  other  The duration to add 
Returns
Type  Description 

Duration  A new Duration representing the result of the addition. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Subtract(Duration, Duration)
operator()
.
Declaration
public static Duration Subtract(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the difference of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
ToBigIntegerNanoseconds()
Declaration
public BigInteger ToBigIntegerNanoseconds()
Returns
Type  Description 

BigInteger  This duration as a number of nanoseconds, represented as a BigInteger . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
ToInt64Nanoseconds()
Int64
, which is approximately 292 years (positive or negative).
Declaration
public long ToInt64Nanoseconds()
Returns
Type  Description 

Int64  This duration as a number of nanoseconds, represented as an Int64 . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Exceptions
Type  Condition 

OverflowException  The number of nanoseconds is outside the representable range. 
ToString()
Declaration
public override string ToString()
Returns
Type  Description 

String  The value of the current instance in the default format pattern ("o"), using the current thread's culture to obtain a format provider. 
Overrides
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
ToString(String, IFormatProvider)
Declaration
public string ToString(string patternText, IFormatProvider formatProvider)
Parameters
Type  Name  Description 

String  patternText  The String specifying the pattern to use, or null to use the default format pattern ("o"). 
IFormatProvider  formatProvider  The IFormatProvider to use when formatting the value, or null to use the current thread's culture to obtain a format provider. 
Returns
Type  Description 

String  A String containing the value of the current instance in the specified format. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
ToTimeSpan()
Declaration
public TimeSpan ToTimeSpan()
Returns
Type  Description 

TimeSpan  A new TimeSpan with the same number of ticks as this Duration. 
Remarks
Exceptions
Type  Condition 

OverflowException  The number of ticks cannot be represented a signed 64bit integer. 
Operators
Addition(Duration, Duration)
Declaration
public static Duration operator +(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the sum of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Division(Duration, Duration)
Declaration
public static double operator /(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Double  The Double representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Division(Duration, Double)
Declaration
public static Duration operator /(Duration left, double right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Double  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Division(Duration, Int64)
Declaration
public static Duration operator /(Duration left, long right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Int64  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of dividing left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Equality(Duration, Duration)
Declaration
public static bool operator ==(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if values are equal to each other, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
GreaterThan(Duration, Duration)
Declaration
public static bool operator>(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if the left value is greater than the right value, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
GreaterThanOrEqual(Duration, Duration)
Declaration
public static bool operator >=(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if the left value is greater than or equal to the right value, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Inequality(Duration, Duration)
Declaration
public static bool operator !=(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if values are not equal to each other, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
LessThan(Duration, Duration)
Declaration
public static bool operator <(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if the left value is less than the right value, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
LessThanOrEqual(Duration, Duration)
Declaration
public static bool operator <=(Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Boolean  true if the left value is less than or equal to the right value, otherwise false . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Duration, Double)
Declaration
public static Duration operator *(Duration left, double right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Double  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of multiplying left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Duration, Int64)
Declaration
public static Duration operator *(Duration left, long right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Int64  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of multiplying left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Multiply(Int64, Duration)
Declaration
public static Duration operator *(long left, Duration right)
Parameters
Type  Name  Description 

Int64  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the result of multiplying left by
right . 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Subtraction(Duration, Duration)
Declaration
public static Duration operator (Duration left, Duration right)
Parameters
Type  Name  Description 

Duration  left  The left hand side of the operator. 
Duration  right  The right hand side of the operator. 
Returns
Type  Description 

Duration  A new Duration representing the difference of the given values. 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
UnaryNegation(Duration)
Declaration
public static Duration operator (Duration duration)
Parameters
Type  Name  Description 

Duration  duration  Duration to negate 
Returns
Type  Description 

Duration  The negative value of this duration 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Explicit Interface Implementations
IComparable.CompareTo(Object)
Declaration
int IComparable.CompareTo(object obj)
Parameters
Type  Name  Description 

Object  obj  The object to compare this value with. 
Returns
Type  Description 

Int32  The result of comparing this instant with another one; see CompareTo(Duration) for general details.
If obj is null, this method returns a value greater than 0.

Remarks
Exceptions
Type  Condition 

ArgumentException  obj is nonnull but does not refer to an instance of Duration. 
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
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Exceptions
Type  Condition 

ArgumentNullException  info is null. 
IXmlSerializable.GetSchema()
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type  Description 

XmlSchema 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
IXmlSerializable.ReadXml(XmlReader)
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type  Name  Description 

XmlReader  reader 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Exceptions
Type  Condition 

ArgumentNullException  reader is null. 
IXmlSerializable.WriteXml(XmlWriter)
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type  Name  Description 

XmlWriter  writer 
Remarks
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 Instant from an earlier one.
A duration represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.
In general, use Duration to represent durations applied to global types like Instant
and ZonedDateTime; use Period
to represent a period applied to local types like
LocalDateTime.
The range of valid values of a Duration
is greater than the span of time supported by Noda Time  so for
example, subtracting one Instant from another will always give a valid Duration
. The range
is also greater than that of TimeSpan (MinValue ticks to MaxValue ticks).
See the user guide for more details of the exact range, but it is not expected that this will ever be exceeded in normal code.
Various operations accept or return a Double, inkeeping with durations often being natural lengths
of time which are imprecisely measured anyway. The implementation of these operations should never result in a notanumber
or infinite value, nor do any operations accept notanumber or infinite values. Additionally, operations involving
Double
have initially been implemented fairly naïvely; it's possible that future releases will improve the accuracy
or performance (or both) of various operations.
Exceptions
Type  Condition 

ArgumentNullException  writer is null. 