Class TimeSpanUtility
Namespace: UnityEngine.Localization.SmartFormat.Utilities
Syntax
public static class TimeSpanUtility
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
Ceiling(TimeSpan, Int64)
Returns the smallest TimeSpan
greater than or equal to the specified interval.
For example: Ceiling("00:57:00", TimeSpan.TicksPerMinute * 5) => "01:00:00"
Declaration
[Obsolete("Use System.Math.Ceiling(int) instead", true)]
public static TimeSpan Ceiling(this TimeSpan fromTime, long intervalTicks)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | fromTime | A |
Int64 | intervalTicks | Specifies the interval for rounding. Use |
Returns
Type | Description |
---|---|
TimeSpan |
Floor(TimeSpan, Int64)
Returns the largest TimeSpan
less than or equal to the specified interval.
For example: Floor("00:57:00", TimeSpan.TicksPerMinute * 5) => "00:55:00"
Declaration
[Obsolete("Use System.Math.Floor(int) instead", true)]
public static TimeSpan Floor(this TimeSpan FromTime, long intervalTicks)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | FromTime | A |
Int64 | intervalTicks | Specifies the interval for rounding. Use |
Returns
Type | Description |
---|---|
TimeSpan |
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 |
Int64 | intervalTicks | Specifies the interval for rounding. Use |
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 |