Return handle for job is null when scheduling a "Date" based Job #5

Closed
nbose opened this Issue Feb 16, 2012 · 1 comment

Projects

None yet

2 participants

@nbose
nbose commented Feb 16, 2012

Hello,

The return handle is null when scheduling a job based on a Date object.

var schedule = require('node-schedule');
var d = new Date(2012, 1, 16, 10, 15, 40);

var j = schedule.scheduleJob(d, function(){
    console.log('The world is going to end today.');
});
console.log(j);

-- Output is null

The fix I believe is below

Job.prototype.schedule = function(spec){
    var success = false;
    var job = this;

    if (typeof(spec) == 'object' && spec instanceof Date)
    {
        var inv = new Invocation(this, spec);
        scheduleInvocation(inv);
        success = this.trackInvocation(inv);
    }
....

compared to the existing code which is

success = scheduleInvocation(inv);
    if (success)
    this.trackInvocation(inv);

Thanks,
Nithin

@mattpat mattpat added a commit that referenced this issue Feb 16, 2012
@mattpat mattpat Fixed issue #5 563b545
@mattpat
Collaborator
mattpat commented Feb 16, 2012

Thanks for the catch, you're absolutely right. Fixed! :)

@mattpat mattpat closed this Feb 16, 2012
@macalinao macalinao added a commit to macalinao/node-schedule that referenced this issue Jan 3, 2015
@macalinao macalinao Fixed issue #5 e1a8206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment