Return to Snippet

Revision: 39967
at January 24, 2011 07:01 by kyrathaba


Initial Code
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;
        }


    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Converting seconds to an appropriate string description

Initial Tags

                                

Initial Language
C#