Class TimeSpanExtenstions
Provides extension methods for working with TimeSpan objects.
Inherited Members
Namespace: mk.helpers
Assembly: mk.helpers.dll
Syntax
public static class TimeSpanExtenstions
Methods
Multiply(TimeSpan, int)
Multiplies a TimeSpan by a specified multiplier.
Declaration
public static TimeSpan Multiply(this TimeSpan timeSpan, int multiplier)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeSpan | The TimeSpan to be multiplied. |
| int | multiplier | The multiplier value. |
Returns
| Type | Description |
|---|---|
| TimeSpan | The result of the multiplication as a new TimeSpan. |
RoundToNearest(TimeSpan, TimeSpan)
Declaration
public static TimeSpan RoundToNearest(this TimeSpan a, TimeSpan roundTo)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | a | The TimeSpan to be rounded. |
| TimeSpan | roundTo | The TimeSpan multiple to round to. |
Returns
| Type | Description |
|---|---|
| TimeSpan | The rounded TimeSpan. |
Sum(IEnumerable<TimeSpan>)
Calculates the sum of a collection of TimeSpan objects.
Declaration
public static TimeSpan Sum(this IEnumerable<TimeSpan> timeSpans)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TimeSpan> | timeSpans | The collection of TimeSpan objects. |
Returns
| Type | Description |
|---|---|
| TimeSpan | The sum of the TimeSpan objects. |
ToHumanTimeString(TimeSpan, int)
Converts a TimeSpan object to a simple human-readable string representation.
Declaration
public static string ToHumanTimeString(this TimeSpan span, int significantDigits = 3)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | span | The TimeSpan to be converted. |
| int | significantDigits | The number of significant digits to use for output. Default is 3. |
Returns
| Type | Description |
|---|---|
| string | The human-readable string representation of the TimeSpan. |