File size: 371 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import { DateTime } from 'luxon';
import cronParser from 'cron-parser';

export default function getNextCronDateTime(cronString) {
  const cronDate = cronParser.parseExpression(cronString);
  const matchingNextCronDateTime = cronDate.next();
  const matchingNextDateTime = DateTime.fromJSDate(
    matchingNextCronDateTime.toDate()
  );

  return matchingNextDateTime;
}