Skip to content

Commit

Permalink
Merge pull request #410 from shuat/master
Browse files Browse the repository at this point in the history
Fix DST Bug by adding 2 hours when 2AM does not exists
  • Loading branch information
ncb000gt authored Mar 10, 2019
2 parents 901005b + 849a246 commit 2db8113
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,17 @@
Object.keys(this.hour).length !== 24
) {
origDate = moment(date);
var curHour = date.hours();
date.hours(
date.hours() === 23 && diff > 86400000 ? 0 : date.hours() + 1
date.hours() === 23 && diff > 86400000 ? 0 : date.hours() + 1
);
/*
* Moment Date will not allow you to set the time to 2 AM if there is no 2 AM (on the day we change the clock)
* We will therefore jump to 3AM if time stayed at 1AM
*/
if(curHour === date.hours()){
date.hours(date.hours() + 2);
}
date.minutes(0);
date.seconds(0);
if (date <= origDate) {
Expand Down

0 comments on commit 2db8113

Please sign in to comment.