opensim/OpenSim/Framework/Util.cs
/// <summary>
/// Formats a duration (given in milliseconds).
/// </summary>
Formats a duration (given in milliseconds).
Formats a duration ( given in milliseconds ) .
public static string FormatDuration(int ms)
        {
            TimeSpan span = new TimeSpan(ms * TimeSpan.TicksPerMillisecond);
            string str = "";
            string suffix = null;
            int hours = (int)span.TotalHours;
            if (hours > 0)
            {
                str += hours.ToString(str.Length == 0 ? "0" : "00");
                suffix = "hours";
            }
            if ((hours > 0) || (span.Minutes > 0))
            {
                if (str.Length > 0)
                    str += ":";
                str += span.Minutes.ToString(str.Length == 0 ? "0" : "00");
                if (suffix == null)
                    suffix = "min";
            }
            if ((hours > 0) || (span.Minutes > 0) || (span.Seconds > 0))
            {
                if (str.Length > 0)
                    str += ":";
                str += span.Seconds.ToString(str.Length == 0 ? "0" : "00");
                if (suffix == null)
                    suffix = "sec";
            }
            if (suffix == null)
                suffix = "ms";
            if (span.TotalMinutes < 1)
            {
                int ms1 = span.Milliseconds;
                if (str.Length > 0)
                {
                    ms1 /= 100;
                    str += ".";
                }
                str += ms1.ToString("0");
            }
            str += " " + suffix;
            return str;
        }
public static string FormatDuration ( int ms ) { TimeSpan span = new TimeSpan ( ms * TimeSpan . TicksPerMillisecond ) ; string str = " " ; string suffix = null ; int hours = ( int ) span . TotalHours ; if ( hours > 0 ) { str += hours . ToString ( str . Length == 0 ? " " : " " ) ; suffix = " " ; } if ( ( hours > 0 ) || ( span . Minutes > 0 ) ) { if ( str . Length > 0 ) str += " " ; str += span . Minutes . ToString ( str . Length == 0 ? " " : " " ) ; if ( suffix == null ) suffix = " " ; } if ( ( hours > 0 ) || ( span . Minutes > 0 ) || ( span . Seconds > 0 ) ) { if ( str . Length > 0 ) str += " " ; str += span . Seconds . ToString ( str . Length == 0 ? " " : " " ) ; if ( suffix == null ) suffix = " " ; } if ( suffix == null ) suffix = " " ; if ( span . TotalMinutes < 1 ) { int ms1 = span . Milliseconds ; if ( str . Length > 0 ) { ms1 /= 100 ; str += " " ; } str += ms1 . ToString ( " " ) ; } str += " " + suffix ; return str ; }
Formats a duration (given in milliseconds).
Formats a duration ( given in milliseconds ) .
ms
int