RoundedTimeSpan StructureCleanCode C# Libraries v1.2.03 API
Use this struct to generate rounded TimeSpan values.

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

public struct RoundedTimeSpan
Remarks

The standard TimeSpan struct renders like this:
Console.WriteLine(new TimeSpan(19365678)) => 00:00:01.9365678
A RoundedTimeSpan struct, on the other hand, lets you adjust the precision:
Console.WriteLine(new RoundedTimeSpan(19365678, 5)) => 00:00:01.93657
Console.WriteLine(new RoundedTimeSpan(19365678, 3)) => 00:00:01.937
Those values implicitly come from the default ToString  method. There is an additional convenience method to generate a string with displayed digits different than the precision:
Console.WriteLine(new RoundedTimeSpan(19365678, 3).ToString(5)) => 00:00:01.93700
Be aware, however, that if the precision in your constructor is greater than the length specified to display, then ToString(Int32) effectively is truncating rather than rounding.

Since CleanCode 0.9.31.

See Also