RoundedTimeSpan ToString Method (Int32)CleanCode C# Libraries v1.2.03 API
Returns the TimeSpan value rounded to the precision specified in the constructor then trimmed to the length specified here.

Namespace: CleanCode.Data
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public string ToString(
	int length
)

Parameters

length
Type: OnlineSystem Int32
The display length, a value between -9 and +7 inclusive.

Return Value

A string representation of a TimeSpan rounded and padded with zeroes.
Remarks

This method first rounds the TimeSpan to the specified precision, then trims to the length indicated.
  • If the length is greater than the precision the result is filled to the right with zeroes to that length.
  • If the length is less than the precision the result is truncated to that length (so you have lost the benefit of rounding).
  • The milliseconds of a TimeSpan object occupies seven characters so you may at most specify a length of 7.
  • If the precision is specified as zero, the milliseconds are not shown at all, so calling this method would be identical to calling ToString .
  • If the length is 0, all milliseconds are suppressed but the decimal point is displayed.
  • If the length is negative, you start trimming the decimal point, then the seconds then minutes then hours. These take a total of nine characters so you may specify up to -9.
See Also