Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
dada una fecha y una expresión cron, ¿puede validar que la fecha sea parte de la expresión cron?

Tengo una expresión cron y necesito verificar si una fecha determinada es parte de ella (lo que significa que el cron se activaría en esa fecha) (usando nodejs)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar el paquete cron-parser y hacer algo como esto:

 const isDateMatchesCronExpression = (expression, date, scope = 'second') => { scope = ['second', 'minute', 'hour', 'day', 'month', 'weekday'].indexOf(scope.toLowerCase()); try { const data = cronParser.parseExpression(expression).fields; if (scope <= 0 && !data.second.includes(date.getSeconds())) return false; if (scope <= 1 && !data.minute.includes(date.getMinutes())) return false; if (scope <= 2 && !data.hour.includes(date.getHours())) return false; if (scope <= 3 && !data.dayOfMonth.includes(date.getDate())) return false; if (scope <= 4 && !data.month.includes(date.getMonth() + 1)) return false; if (scope <= 5 && !data.dayOfWeek.includes(date.getDay())) return false; return true; } catch (e) { throw new Error(`isDateMatchesCronExpression error: ${e}`); } };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!