tool.js中getsec()方法未定义
stillyu opened this issue · comments
stillyu commented
tool.js中getsec()方法未定义
Yige commented
/**
* 根据含义字符串换算对应的毫秒数
* @param {[type]} str 字符串
* @return {[type]} ms
*/
let getsec = function (str) {
if (/[s|h|d|l]/i.test(str)) {
var str1 = str.substring(0, str.length - 1)
var str2 = str.substring(str.length - 1, str.length)
if (str2 === 's') {
return str1 * 1000
} else if (str2 === 'h') {
return str1 * 60 * 60 * 1000
} else if (str2 === 'd') {
return str1 * 24 * 60 * 60 * 1000
}
} else {
if (str.indexOf('l') === -1) {
return str * 1000
} else {
return 30 * 24 * 60 * 60 * 1000
}
}
}