mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class TimeSpanExtenstions

    Provides extension methods for working with TimeSpan objects.

    Inheritance
    object
    TimeSpanExtenstions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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)

    Rounds the given TimeSpan to the nearest multiple of the specified 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.

    In this article
    Back to top mk.helpers - MIT License