Class TimeSpanExtensions
- Namespace
- Cuemon.Extensions
- Assembly
- Cuemon.Extensions.Core.dll
Extension methods for the System.TimeSpan struct.
public static class TimeSpanExtensions
- Inheritance
-
ObjectTimeSpanExtensions
Fields
TicksPerMicrosecond
Represents the number of ticks in 1 microsecond. This field is constant.
public const double TicksPerMicrosecond = 10
Field Value
- Double
TicksPerNanosecond
Represents the number of ticks in 1 nanosecond. This field is constant.
public const double TicksPerNanosecond = 0.01
Field Value
- Double
Methods
Ceiling(TimeSpan, Double, TimeUnit)
Returns a System.TimeSpan value that is rounded towards positive infinity.
public static TimeSpan Ceiling(this TimeSpan value, double interval, TimeUnit timeUnit)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
DoubleThe System.Double value that in combination with
timeUnit
specifies the rounding ofvalue
.timeUnit
TimeUnitOne of the enumeration values that specifies the time unit of
interval
.
Returns
- TimeSpan
A System.TimeSpan value that is rounded towards positive infinity.
Ceiling(TimeSpan, TimeSpan)
Returns a System.TimeSpan value that is rounded towards positive infinity.
public static TimeSpan Ceiling(this TimeSpan value, TimeSpan interval)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
TimeSpanThe System.TimeSpan value that specifies the rounding of
value
.
Returns
- TimeSpan
A System.TimeSpan value that is rounded towards positive infinity.
Floor(TimeSpan, Double, TimeUnit)
Returns a System.TimeSpan value that is rounded towards negative infinity.
public static TimeSpan Floor(this TimeSpan value, double interval, TimeUnit timeUnit)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
DoubleThe System.Double value that in combination with
timeUnit
specifies the rounding ofvalue
.timeUnit
TimeUnitOne of the enumeration values that specifies the time unit of
interval
.
Returns
- TimeSpan
A System.TimeSpan value that is rounded towards negative infinity.
Floor(TimeSpan, TimeSpan)
Returns a System.TimeSpan value that is rounded towards negative infinity.
public static TimeSpan Floor(this TimeSpan value, TimeSpan interval)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
TimeSpanThe System.TimeSpan value that specifies the rounding of
value
.
Returns
- TimeSpan
A System.TimeSpan value that is rounded towards negative infinity.
GetTotalMicroseconds(TimeSpan)
Gets the total number of microseconds represented by the specified System.TimeSpan structure.
public static double GetTotalMicroseconds(this TimeSpan value)
Parameters
value
TimeSpanThe System.TimeSpan to extend.
Returns
- Double
The total number of microseconds represented by the specified System.TimeSpan structure.
GetTotalNanoseconds(TimeSpan)
Gets the total number of nanoseconds represented by the specified System.TimeSpan structure.
public static double GetTotalNanoseconds(this TimeSpan value)
Parameters
value
TimeSpanThe System.TimeSpan to extend.
Returns
- Double
The total number of nanoseconds represented by the specified System.TimeSpan structure.
Round(TimeSpan, Double, TimeUnit, VerticalDirection)
Returns a System.TimeSpan value that is rounded either towards negative infinity or positive infinity.
public static TimeSpan Round(this TimeSpan value, double interval, TimeUnit timeUnit, VerticalDirection direction)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
DoubleThe System.Double value that in combination with
timeUnit
specifies the rounding ofvalue
.timeUnit
TimeUnitOne of the enumeration values that specifies the time unit of
interval
.direction
VerticalDirectionOne of the enumeration values that specifies the direction of the rounding.
Returns
- TimeSpan
A System.TimeSpan value that is rounded either towards negative infinity or positive infinity.
Exceptions
- System.ArgumentOutOfRangeException
direction
is an invalid enumeration value.
Round(TimeSpan, TimeSpan, VerticalDirection)
Returns a System.TimeSpan value that is rounded either towards negative infinity or positive infinity.
public static TimeSpan Round(this TimeSpan value, TimeSpan interval, VerticalDirection direction)
Parameters
value
TimeSpanA System.TimeSpan value to be rounded.
interval
TimeSpanThe System.TimeSpan value that specifies the rounding of
value
.direction
VerticalDirectionOne of the enumeration values that specifies the direction of the rounding.
Returns
- TimeSpan
A System.TimeSpan value that is rounded either towards negative infinity or positive infinity.
Exceptions
- System.ArgumentOutOfRangeException
direction
is an invalid enumeration value.