Class TimeSpanExtensions
Extension methods for the System.TimeSpan structure.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class TimeSpanExtensions
Fields
| Improve this DocTicksPerMicrosecond
Represents the number of ticks in 1 microsecond. This field is constant.
Declaration
public const double TicksPerMicrosecond = 10
Field Value
Type | Description |
---|---|
System.Double |
TicksPerNanosecond
Represents the number of ticks in 1 nanosecond. This field is constant.
Declaration
public const double TicksPerNanosecond = 0.01
Field Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this DocCeiling(TimeSpan, Double, TimeUnit)
Returns a System.TimeSpan value that is rounded towards positive infinity.
Declaration
public static TimeSpan Ceiling(this TimeSpan value, double interval, TimeUnit timeUnit)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static TimeSpan Ceiling(this TimeSpan value, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static TimeSpan Floor(this TimeSpan value, double interval, TimeUnit timeUnit)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static TimeSpan Floor(this TimeSpan value, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
Returns
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan value that is rounded towards negative infinity. |
GetMicroseconds(TimeSpan)
Gets the microseconds of the time interval represented by the specified System.TimeSpan structure.
Declaration
public static int GetMicroseconds(this TimeSpan ts)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | ts | The System.TimeSpan to extend with a microseconds component. |
Returns
Type | Description |
---|---|
System.Int32 | The millisecond component by the specified System.TimeSpan structure. The return value ranges from -999 through 999. |
GetNanoseconds(TimeSpan)
Gets the nanoseconds of the time interval represented by the specified System.TimeSpan structure.
Declaration
public static int GetNanoseconds(this TimeSpan ts)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | ts | The System.TimeSpan to extend with a nanoseconds component. |
Returns
Type | Description |
---|---|
System.Int32 | The nanoseconds component by the specified System.TimeSpan structure. The return value ranges from -999 through 999. |
GetTotalMicroseconds(TimeSpan)
Gets the total number of microseconds represented by the specified System.TimeSpan structure.
Declaration
public static double GetTotalMicroseconds(this TimeSpan ts)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | ts | The System.TimeSpan to extend. |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static double GetTotalNanoseconds(this TimeSpan ts)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | ts | The System.TimeSpan to extend. |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static TimeSpan Round(this TimeSpan value, double interval, TimeUnit timeUnit, VerticalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.Double | interval | The System.Double value that in combination with |
TimeUnit | timeUnit | One of the enumeration values that specifies the time unit of |
VerticalDirection | direction | One of the enumeration values that specifies the direction of the rounding. |
Returns
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan value that is rounded either towards negative infinity or positive infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Round(TimeSpan, TimeSpan, VerticalDirection)
Returns a System.TimeSpan value that is rounded either towards negative infinity or positive infinity.
Declaration
public static TimeSpan Round(this TimeSpan value, TimeSpan interval, VerticalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | A System.TimeSpan value to be rounded. |
System.TimeSpan | interval | The System.TimeSpan value that specifies the rounding of |
VerticalDirection | direction | One of the enumeration values that specifies the direction of the rounding. |
Returns
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan value that is rounded either towards negative infinity or positive infinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|