|
TimeSpanExtensionsToElapsedTimeString Method
|
Converts the
TimeSpan value into a textual representation of years, days, hours,
minutes and seconds with the specified number of fractional digits.
Namespace: GSFAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax public static string ToElapsedTimeString(
this TimeSpan value,
int secondPrecision = 2,
double minimumSubSecondResolution = 0.001
)
[<ExtensionAttribute>]
static member ToElapsedTimeString :
value : TimeSpan *
?secondPrecision : int *
?minimumSubSecondResolution : float
(* Defaults:
let _secondPrecision = defaultArg secondPrecision 2
let _minimumSubSecondResolution = defaultArg minimumSubSecondResolution 0.001
*)
-> string
GSF.TimeSpanExtensions.ToElapsedTimeString = function(value, secondPrecision, minimumSubSecondResolution);
View SourceParameters
- value TimeSpan
- The TimeSpan to process.
- secondPrecision Int32 (Optional)
- Number of fractional digits to display for seconds. Defaults to 2.
- minimumSubSecondResolution Double (Optional)
- Minimum sub-second resolution to display. Defaults to Milli.
Return Value
String
The string representation of the value of this
TimeSpan, consisting of the number of
years, days, hours, minutes and seconds represented by this value.
Usage Note
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).
Exceptions Remarks Set second precision to -1 to suppress seconds display.
Example
DateTime g_start = DateTime.UtcNow;
DateTime EndTime = DateTime.UtcNow;
TimeSpan duration = EndTime.Subtract(g_start);
Console.WriteLine("Elapsed Time = " + duration.ToElapsedTimeString());
See Also