Net.Bluewalk.DotNetUtils/Extensions/TimeSpanExtensions.cs
/// <summary>
/// Rounds the specified TimeSpan with rounding interval.
/// </summary>
/// <param name="time">The time.</param>
/// <param name="roundingInterval">The rounding interval.</param>
/// <param name="roundingType">Type of the rounding.</param>
/// <returns>TimeSpan.</returns>
Rounds the specified TimeSpan with rounding interval.
Rounds the specified TimeSpan with rounding interval .
public static TimeSpan Round(this TimeSpan time, TimeSpan roundingInterval, MidpointRounding roundingType)
        {
            return new(
                Convert.ToInt64(Math.Round(
                    time.Ticks / (decimal) roundingInterval.Ticks,
                    roundingType
                )) * roundingInterval.Ticks
            );
        }
public static TimeSpan Round ( this TimeSpan time , TimeSpan roundingInterval , MidpointRounding roundingType ) { return new ( Convert . ToInt64 ( Math . Round ( time . Ticks / ( decimal ) roundingInterval . Ticks , roundingType ) ) * roundingInterval . Ticks ) ; }
Rounds the specified TimeSpan with rounding interval.
Rounds the specified TimeSpan with rounding interval .
None
TimeSpan
this
roundingInterval
TimeSpan
The rounding interval.
The rounding interval .
roundingType
MidpointRounding
Type of the rounding.
Type of the rounding .
time
None