/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
namespace Kyrathasoft.Conversions.GetDurationDescription { using System; public static class clsGetDurationDesc { public static string getDurationDesc(double numMilliseconds) { const double Minute = 60000; const double Second = 1000; double duration = 0; string result = string.Empty; if (numMilliseconds >= Minute) { duration = numMilliseconds / Minute; //result = String.Format("{0:0.00}", duration) + " minutes"; result = duration.ToString("N3") + " minutes"; } else { if (numMilliseconds >= Second) { duration = numMilliseconds / Second; //result = String.Format("{0:00}", duration) + " seconds"; result = duration.ToString("N3") + " seconds"; } else { result = numMilliseconds.ToString() + " milliseconds"; } } return result; } } }