docs.unity3d.com
    Show / Hide Table of Contents

    Class TimeSpanUtility

    Inheritance
    Object
    TimeSpanUtility
    Namespace: UnityEngine.Localization.SmartFormat.Utilities
    Syntax
    public static class TimeSpanUtility : object

    Properties

    AbsoluteDefaults

    These are the absolute default options that will be used as a safeguard, just in case DefaultFormatOptions is missing a value.

    Declaration
    public static TimeSpanFormatOptions AbsoluteDefaults { get; }
    Property Value
    Type Description
    TimeSpanFormatOptions

    DefaultFormatOptions

    These are the default options that will be used when no option is specified.

    Declaration
    public static TimeSpanFormatOptions DefaultFormatOptions { get; set; }
    Property Value
    Type Description
    TimeSpanFormatOptions

    Methods

    Round(TimeSpan, Int64)

    Returns the TimeSpan closest to the specified interval.

    For example: Round("00:57:00", TimeSpan.TicksPerMinute * 5) => "00:55:00"

    Declaration
    public static TimeSpan Round(this TimeSpan FromTime, long intervalTicks)
    Parameters
    Type Name Description
    TimeSpan FromTime

    A TimeSpan to be rounded.

    Int64 intervalTicks

    Specifies the interval for rounding. Use TimeSpan.TicksPer____.

    Returns
    Type Description
    TimeSpan

    ToTimeString(TimeSpan, TimeSpanFormatOptions, TimeTextInfo)

    Turns a TimeSpan into a human-readable text.

    Uses the specified timeSpanFormatOptions.

    For example: "31.23:59:00.555" = "31 days 23 hours 59 minutes 0 seconds 555 milliseconds"

    Declaration
    public static string ToTimeString(this TimeSpan FromTime, TimeSpanFormatOptions options, TimeTextInfo timeTextInfo)
    Parameters
    Type Name Description
    TimeSpan FromTime
    TimeSpanFormatOptions options

    A combination of flags that determine the formatting options.

    These will be combined with the default timeSpanFormatOptions.

    TimeTextInfo timeTextInfo

    An object that supplies the text to use for output

    Returns
    Type Description
    String
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023