diff --git a/lib/cron.js b/lib/cron.js index ec9b80d6..4c007d9c 100644 --- a/lib/cron.js +++ b/lib/cron.js @@ -124,16 +124,9 @@ return date; } - //add 1 second so next time isn't now (can cause timeout to be 0 or negative number) var now = new Date(); var targetSecond = date.seconds(); var diff = Math.abs(targetSecond - now.getSeconds()) - // there was a problem when `date` is 1424777177999 and `now` is 1424777178000 - // 1 ms diff but this is another second... - if ( diff == 0 || (diff == 1 && now.getMilliseconds() <= date.milliseconds() ) ) { - //console.log('add 1 second?'); - date = date.add(1, 's'); - } //If the i argument is not given, return the next send time if (isNaN(i) || i < 0) { @@ -146,8 +139,7 @@ for (; i > 0; i--) { date = this._getNextDateFrom(date); dates.push(moment(date)); - if (i > 1) - date.add(1,'s'); + } return dates; @@ -272,13 +264,12 @@ if(date.valueOf()==start){ date.seconds(date.seconds()+1); + continue; } break; } - if(origDate.valueOf()==start){ - date.seconds(date.seconds()-1); - } + return date; },