Noda Time
Show / Hide Table of Contents

Class TimeSpanExtensions

Extension methods for System.TimeSpan.
Since 2.0.x
Availability netstandard2.0
Inheritance
Object
TimeSpanExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: NodaTime.Extensions
Assembly: NodaTime.dll
Syntax
public static class TimeSpanExtensions

Methods

ToDuration(TimeSpan)

Converts a System.TimeSpan into a Duration.
Since 2.0.x
Availability 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)

Converts a System.TimeSpan into an Offset.
Since 2.0.x
Availability 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.
In this article
Back to top Generated by DocFX