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AAG,CAAC,CAAC,CAAC;gBAC3C,IAAI,IAAI,EAAE;oBACR,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBACvC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;wBAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;qBACxC;iBACF;gBACD,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBACtC,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC","file":"utils.js","sourcesContent":["export interface TimeData {\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n milliseconds: number;\n}\n\nconst SECOND = 1000;\nconst MINUTE = 60 * SECOND;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\n\nexport const parseTimeData = function (time: number): TimeData {\n const days = Math.floor(time / DAY);\n const hours = Math.floor((time % DAY) / HOUR);\n const minutes = Math.floor((time % HOUR) / MINUTE);\n const seconds = Math.floor((time % MINUTE) / SECOND);\n const milliseconds = Math.floor(time % SECOND);\n return {\n days,\n hours,\n minutes,\n seconds,\n milliseconds,\n };\n};\n\nexport const isSameSecond = function (time1: number, time2: number): boolean {\n return Math.floor(time1 / 1000) === Math.floor(time2 / 1000);\n};\n\nexport type TTimeList = { digit: string; unit: string; match: string }[];\n\n/**\n *\n * @param time 倒计时时间,毫秒单位\n * @param format 倒计时格式化字符串,例如:dd天hh小时mm分ss秒SSS毫秒,hh:mm:ss.SSS,hh:mm:ss\n */\nexport const parseFormat = function (time: number, format: string) {\n const obj = {\n 'D+': Math.floor(time / 86400000), // 日\n 'H+': Math.floor((time % 86400000) / 3600000), // 小时\n 'm+': Math.floor((time % 3600000) / 60000), // 分\n 's+': Math.floor((time % 60000) / 1000), // 秒\n 'S+': Math.floor(time % 1000), // 毫秒\n };\n const timeList: TTimeList = [];\n let timeText = format;\n\n Object.keys(obj).forEach((prop) => {\n if (new RegExp(`(${prop})`).test(timeText)) {\n timeText = timeText.replace(RegExp.$1, (match, offset, source) => {\n const v = `${(obj as any)[prop]}`;\n let digit = v;\n if (match.length > 1) {\n digit = (match.replace(new RegExp(match[0], 'g'), '0') + v).substr(v.length);\n }\n const unit = source.substr(offset + match.length);\n const last = timeList[timeList.length - 1];\n if (last) {\n const index = last.unit.indexOf(match);\n if (index !== -1) {\n last.unit = last.unit.substr(0, index);\n }\n }\n timeList.push({ digit, unit, match });\n return digit;\n });\n }\n });\n return { timeText, timeList };\n};\n"]}