m
This commit is contained in:
15
src/utils/index.js
Normal file
15
src/utils/index.js
Normal file
@ -0,0 +1,15 @@
|
||||
function isValidDateTime(datetimeStr) {
|
||||
// 尝试将字符串转换为 Date 对象
|
||||
const date = new Date(datetimeStr);
|
||||
|
||||
// 检查转换后的日期是否是有效日期
|
||||
return !isNaN(date.getTime()) &&
|
||||
date.toString() !== 'Invalid Date';
|
||||
}
|
||||
async function randomDelay(min = 5000, max = 20000) {
|
||||
const delay = Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
await new Promise(resolve => setTimeout(resolve, delay));
|
||||
}
|
||||
|
||||
|
||||
module.exports = { isValidDateTime, randomDelay };
|
Reference in New Issue
Block a user