Cron parser with later

https://bunkat.github.io/later/

 

later.date.localTime();
var cron = ‘* 10-12 * * *’;

var s = later.parse.cron(cron);

var current=new Date();
console.log(current);

var prev=later.schedule(s).prev();
console.log(prev);

var next=later.schedule(s).next();
console.log(next);

var ismatch=(

prev.getFullYear()==current.getFullYear()
&& next.getFullYear()==current.getFullYear()
&& prev.getMonth()==current.getMonth()
&& next.getMonth()==current.getMonth()
&& prev.getDate()==current.getDate()
&& next.getDate()==current.getDate()

&& prev.getTime()<=current.getTime()
&& next.getTime()>=current.getTime()

)

console.log(ismatch);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s