Click or drag to resize

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: GSF
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.205-beta+5ef4169f3b1079d8b163dd363614f656bd140924
Syntax
public static string ToElapsedTimeString(
	this TimeSpan value,
	int secondPrecision = 2,
	double minimumSubSecondResolution = 0.001
)
View Source

Parameters

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
ExceptionCondition
ArgumentOutOfRangeExceptionminimumSubSecondResolution is not less than or equal to Milli or minimumSubSecondResolution is not defined in Factors array.
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