using System;
using System.Collections.Generic;
using System.Text;

namespace YGNT.Infrastructure.Helper
{
    public static class TimeHelp
    {
        /// <summary>
        /// 秒转为中文的【时分秒】时间（如：62秒，输出：1分2秒）
        /// </summary>
        /// <param name="ss"></param>
        /// <returns></returns>
        public static string FormatSecond(double ss)
        {
            TimeSpan ts = new TimeSpan((long)ss * TimeSpan.TicksPerSecond);

            //string aaa = ts.ToString();
            //string bbbb = ts.ToString(@"hh\时mm\分ss\秒");

            string txt = $"{ts.Seconds}秒";
            if (ts.TotalMinutes >= 1)
            {
                txt = $"{ts.Minutes}分{txt}";

                if (ts.TotalHours >= 1)
                    txt = $"{Math.Round(ts.TotalHours, 0, MidpointRounding.ToZero)}时{txt}";

            }
            return txt;
        }

    }
}
