using JiShe.CollectBus.Common.Extensions;

namespace JiShe.CollectBus.Protocol.AnalysisData
{
    /// <summary>
    /// 附录
    /// </summary>
    public static class Appendix
    {
        /// <summary>
        /// 附录1 A1格式
        /// </summary>
        /// <returns></returns>
        public static string Appendix_A1(List<string> data)
        {
            var seconds = data[0];
            var minutes = data[1];
            var hours = data[2];
            var day = data[3];
            var binString = data[4].HexToBin();
            var months = binString.Substring(3, 1).BinToDec() * 10 + Convert.ToInt32(binString.Substring(4, 4).BinToHex());
            var week = binString.Substring(0, 3).BinToHex();
            var year = $"{DateTime.Now.ToString("yyyy").Substring(0, 2)}{data[5]}";
            return $"{year}-{months.ToString().PadLeft(2, '0')}-{day} {hours}:{minutes}:{seconds}_{week}";
        }

    }
}
