Anders Kitson
Anders Kitson

Reputation: 1545

later.js trying to chain a schedule on a specific date

I am using later.js I am attempting to schedule a post in Meteor.
I haven't even got to the scheduling part yet because I am having trouble understanding how later.js recur() works by chaining time periods together, and execute a function that will eventually find data that was inserted in a collection out output in html.

I would like to know how to run the function on a specified date. month 'may'(5) day '15' and time 16:00.

I have tried different configurations with no luck

Here is my attempted code:

   var sched = later.parse.recur().on(16).hour().and().on(15).dayOfMonth().and().on(5).month();

  t = later.setTimeout(test, sched);
  function test() {
    console.log("insert Data");
  }

Upvotes: 0

Views: 1017

Answers (2)

jitsu553
jitsu553

Reputation: 56

I hope this helps and its not too late

CODE

var sched=later.parse.recur().on(15).dayOfMonth().on(5).month().on(16).hour(),
t = later.setTimeout(test, sched);
function test()
{
   console.log("insert Data")
}

Upvotes: 0

RainTeller
RainTeller

Reputation: 23

I think you'll be best using percolate:synced-cron package that will do this stuff for you :)

Basic example from the README.md:

SyncedCron.add({
  name: 'Crunch some important numbers for the marketing department',
  schedule: function(parser) {
    // parser is a later.parse object
    return parser.text('every 2 hours');
  },
  job: function() {
    var numbersCrunched = CrushSomeNumbers();
    return numbersCrunched;
  }
});

Upvotes: 2

Related Questions