CSharp · Console
// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002344/double-fromdays
// @nuget: Z.ExtensionMethods
using System;
public class Program
{
public static void Main()
{
double[] values = { 0.000000006, 0.000123456, 1, 5.234567898, 12345.678987654, 0.000011574, 0.000694444, 0.041666666, 1, 20.84745602 };
Console.WriteLine("{0,21}{1,18}","FromDays", "TimeSpan");
Console.WriteLine("{0,21}{1,18}","--------", "--------");
foreach (double value in values)
{
// C# Extension Method: Double - FromDays
TimeSpan interval = value.FromDays();
string timeInterval = interval.ToString();
int pIndex = timeInterval.IndexOf(':');
pIndex = timeInterval.IndexOf('.', pIndex);
if (pIndex < 0) timeInterval += " ";
Console.WriteLine("{0,21}{1,26}", value, timeInterval);
}
}
}