1 line
5.1 KiB
JSON
1 line
5.1 KiB
JSON
|
{"ast":null,"code":"// Countdown\nconst timeUnits = [['Y', 1000 * 60 * 60 * 24 * 365],\n// years\n['M', 1000 * 60 * 60 * 24 * 30],\n// months\n['D', 1000 * 60 * 60 * 24],\n// days\n['H', 1000 * 60 * 60],\n// hours\n['m', 1000 * 60],\n// minutes\n['s', 1000],\n// seconds\n['S', 1] // million seconds\n];\nexport function formatTimeStr(duration, format) {\n let leftDuration = duration;\n const escapeRegex = /\\[[^\\]]*]/g;\n const keepList = (format.match(escapeRegex) || []).map(str => str.slice(1, -1));\n const templateText = format.replace(escapeRegex, '[]');\n const replacedText = timeUnits.reduce((current, _ref) => {\n let [name, unit] = _ref;\n if (current.includes(name)) {\n const value = Math.floor(leftDuration / unit);\n leftDuration -= value * unit;\n return current.replace(new RegExp(`${name}+`, 'g'), match => {\n const len = match.length;\n return value.toString().padStart(len, '0');\n });\n }\n return current;\n }, templateText);\n let index = 0;\n return replacedText.replace(escapeRegex, () => {\n const match = keepList[index];\n index += 1;\n return match;\n });\n}\nexport function formatCountdown(value, config) {\n const {\n format = ''\n } = config;\n const target = new Date(value).getTime();\n const current = Date.now();\n const diff = Math.max(target - current, 0);\n return formatTimeStr(diff, format);\n}","map":{"version":3,"names":["timeUnits","formatTimeStr","duration","format","leftDuration","escapeRegex","keepList","match","map","str","slice","templateText","replace","replacedText","reduce","current","_ref","name","unit","includes","value","Math","floor","RegExp","len","length","toString","padStart","index","formatCountdown","config","target","Date","getTime","now","diff","max"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/statistic/utils.js"],"sourcesContent":["// Countdown\nconst timeUnits = [['Y', 1000 * 60 * 60 * 24 * 365],\n// years\n['M', 1000 * 60 * 60 * 24 * 30],\n// months\n['D', 1000 * 60 * 60 * 24],\n// days\n['H', 1000 * 60 * 60],\n// hours\n['m', 1000 * 60],\n// minutes\n['s', 1000],\n// seconds\n['S', 1] // million seconds\n];\nexport function formatTimeStr(duration, format) {\n let leftDuration = duration;\n const escapeRegex = /\\[[^\\]]*]/g;\n const keepList = (format.match(escapeRegex) || []).map(str => str.slice(1, -1));\n const templateText = format.replace(escapeRegex, '[]');\n const replacedText = timeUnits.reduce((current, _ref) => {\n let [name, unit] = _ref;\n if (current.includes(name)) {\n const value = Math.floor(leftDuration / unit);\n leftDuration -= value * unit;\n return current.replace(new RegExp(`${name}+`, 'g'), match => {\n const len = match.length;\n return value.toString().padStart(len, '0');\n });\n }\n return current;\n }, templateText);\n let index = 0;\n return replacedText.replace(escapeRegex, () => {\n const match = keepList[index];\n index += 1;\n return match;\n });\n}\nexport function formatCountdown(value, config) {\n const {\n format = ''\n } = config;\n const target = new Date(value).getTime();\n const current = Date.now();\n const diff = Math.max(target - current, 0);\n return formatTimeStr(diff, format);\n}"],"mappings":"AAAA;AACA,MAAMA,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AACnD;AACA,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC/B;AACA,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1B;AACA,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AACrB;AACA,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC;AAChB;AACA,CAAC,GAAG,EAAE,IAAI,CAAC;AACX;AACA,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAAA,CACR;AACD,OAAO,SAASC,aAAaA,CAACC,QAAQ,EAAEC,MAAM,EAAE;EAC9C,IAAIC,YAAY,GAAGF,QAAQ;EAC3B,MAAMG,WAAW,GAAG,YAAY;EAChC,MAAMC,QAAQ,GAAG,CAACH,MAAM,CAACI,KAAK,CAACF,WAAW,CAAC,IAAI,EAAE,EAAEG,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;EAC/E,MAAMC,YAAY,GAAGR,MAAM,CAACS,OAAO,CAACP,WAAW,EAAE,IAAI,CAAC;EACtD,MAAMQ,YAAY,GAAGb,SAAS,C
|