Class TimeSpanExtensions
Extension methods for TimeSpan.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Inherited Members
Namespace: NodaTime.Extensions
Assembly: NodaTime.dll
Syntax
public static class TimeSpanExtensions
Methods
ToDuration(TimeSpan)
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static Duration ToDuration(this TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeSpan | The TimeSpan to convert. |
Returns
Type | Description |
---|---|
Duration | A Duration representing the same length of time as timeSpan . |
Remarks
This is a convenience method which calls FromTimeSpan(TimeSpan).
ToOffset(TimeSpan)
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static Offset ToOffset(this TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeSpan | The TimeSpan to convert. |
Returns
Type | Description |
---|---|
Offset | An Offset representing the same length of time as timeSpan . |
Remarks
This is a convenience method which calls FromTimeSpan(TimeSpan).
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | timeSpan is too large or small to
be represented as an Offset . |