Skip to content

Commit

Permalink
Update cronTrigger.js
Browse files Browse the repository at this point in the history
当下一个任务的执行时间跨月的时候,如果本月的最大天数大于下月的最大天数,Date.setMonth()会把月份改成下下个月,所以先执行Date.setDate(),再执行Date.setMonth(),可以保证跨月的时候不会跳月
  • Loading branch information
cooldd100 committed Jun 4, 2014
1 parent fec5c16 commit ef382f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/cronTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pro.nextExcuteTime = function(time){
date.setSeconds(0);
continue;
}
date.setMonth(nextMonth);


date.setDate(1);
date.setMonth(nextMonth);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
Expand All @@ -86,8 +86,8 @@ pro.nextExcuteTime = function(time){

//If the date is in the next month, add month
if(nextDom <= date.getDate() || nextDom > domLimit){
date.setMonth(date.getMonth() + 1);
date.setDate(1);
date.setMonth(date.getMonth() + 1);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
Expand Down

0 comments on commit ef382f6

Please sign in to comment.