import { getCronParser } from '../third-party/cron-parser.mjs';

function getMinute(time) {
  return parseInt("".concat(time / 1000 / 60), 10);
}
function isInCronExpression(cronExpression) {
  if (!cronExpression) {
    return false;
  }
  var parser = getCronParser();
  var options = {
    // 当前时间提前1分钟，否则匹配不到
    currentDate: new Date(Date.now() - 60 * 1000)
  };
  try {
    var interval = parser.parseExpression(cronExpression, options);
    var nextDate = interval.next();
    var nextMinute = getMinute(nextDate.getTime());
    var nowMinute = getMinute(Date.now());
    return nowMinute === nextMinute;
  } catch (err) {
    console.log("[isInCronExpression] Error: ".concat(err.message));
  }
  return false;
}

export { isInCronExpression };
