Class TimeSpanExtensions
TimeSpan extensions.
Namespace: Neon.Common
Assembly: Neon.Common.dll
Syntax
public static class TimeSpanExtensions
Methods
AdjustToFitDateRange(TimeSpan, DateTime)
Adjusts a TimeSpan such that when it is added to a DateTime the resulting date is within the valid possible date range of MinValue...MaxValue. This is useful for timeout related calculations.
Declaration
public static TimeSpan AdjustToFitDateRange(this TimeSpan timespan, DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timespan | The TimeSpan. |
| DateTime | dateTime | The DateTime. |
Returns
| Type | Description |
|---|---|
| TimeSpan | The adjusted TimeSpan. |
RoundToSeconds(TimeSpan)
Rounds positive values up to the nearest second and negative values down to the nearest second.
Declaration
public static TimeSpan RoundToSeconds(this TimeSpan value)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | value | The input value. |
Returns
| Type | Description |
|---|---|
| TimeSpan | The outpot value rounded to seconds. |