TimeSpanExtensionsToElapsedTimeString(TimeSpan, Int32, String, Double) Method
Converts the
TimeSpan value into a textual representation of years, days, hours,
minutes and seconds with the specified number of fractional digits given string array of
time names.
Namespace: Gemstone.TimeSpanExtensionsAssembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.110 -- Release Build+3e0464f4461df4d3e1175b13966eb47ff832554d
public static string ToElapsedTimeString(
this TimeSpan value,
int secondPrecision = 2,
string[]? timeNames = null,
double minimumSubSecondResolution = 0.001
)
Gemstone.TimeSpanExtensions.TimeSpanExtensions.ToElapsedTimeString = function(value, secondPrecision, timeNames, minimumSubSecondResolution);
- value TimeSpan
- The TimeSpan to process.
- secondPrecision Int32 (Optional)
- Number of fractional digits to display for seconds.
- timeNames String (Optional)
- Time names array to use during textual conversion.
- minimumSubSecondResolution Double (Optional)
-
Minimum sub-second resolution to display. Defaults to Milli.
String
The string representation of the value of this instance, consisting of the number of
years, days, hours, minutes and seconds represented by this value.
In Visual Basic and C#, you can call this method as an instance method on any object of type
TimeSpan. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Set secondPrecision to -1 to suppress seconds display, this will
force minimum resolution of time display to minutes.
timeNames array needs one string entry for each of the following names:
" year", " years", " day", " days", " hour", " hours", " minute", " minutes", " second", " seconds", "less than ".
DateTime g_start = DateTime.UtcNow;
DateTime EndTime = DateTime.UtcNow;
TimeSpan duration = EndTime.Subtract(g_start);
Console.WriteLine("Elapsed Time = " + duration.ToElapsedTimeString());