ncb000gt/node-cron — pull request #84 by mle-ii (2014-03-10 06:53:05+00:00)
Title: Update for fixing node-cron to better handle DST.

Here are some tests to verify a few variations of DST and leap year.

```
function testTime(chronString, date, expectedDate) {
var testCronTime = new CronTime(chronString),
actualDate = testCronTime._getNextDateFrom(date);
if (expectedDate - actualDate === 0) {
console.log('\033[42mPASS\033[40m: expected = ' + expectedDate + '; actual = ' + actualDate + '; cronTime = ' + chronString);
} else {
console.error('\033[41mFAIL\033[40m: expected = ' + expectedDate + '; actual = ' + actualDate + '; cronTime = ' + chronString);
}
}
//DST Tests
testTime('*/5 * * * * *', new Date(Date.parse('2014-03-09 01:59:53')), new Date(Date.parse('2014-03-09 01:59:55')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-03-09 01:59:54')), new Date(Date.parse('2014-03-09 01:59:55')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-03-09 01:59:55')), new Date(Date.parse('2014-03-09 01:59:55')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-03-09 01:59:59')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails with current version

testTime('* * * * * *', new Date(Date.parse('2014-03-09 01:59:59')), new Date(Date.parse('2014-03-09 01:59:59')));
testTime('* 0 * * * *', new Date(Date.parse('2014-03-09 01:59:59')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails with current version
testTime('0 * * * * *', new Date(Date.parse('2014-03-09 01:59:55')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails with current version
testTime('0 0 * * * *', new Date(Date.parse('2014-03-09 01:59:55')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails with current version

testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-08 21:00:00')), new Date(Date.parse('2014-03-08 21:00:00')));
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-08 21:00:01')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails and will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-08 20:00:01')), new Date(Date.parse('2014-03-08 21:00:00')));
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 01:00:00')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails and will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 01:00:01')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails and will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 01:01:00')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 01:01:01')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 01:59:59')), new Date(Date.parse('2014-03-09 09:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-03-09 03:00:00')), new Date(Date.parse('2014-03-09 09:00:00')));

testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 01:00:00')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 01:59:00')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 01:59:59')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 01:00:59')), new Date(Date.parse('2014-03-09 03:00:00'))); //Fails will get in infinite loop with current version
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 03:00:00')), new Date(Date.parse('2014-03-09 03:00:00')));
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 03:00:01')), new Date(Date.parse('2014-03-09 04:00:00')));
testTime('00 00 02,03,04 * * *', new Date(Date.parse('2014-03-09 04:00:01')), new Date(Date.parse('2014-03-10 02:00:00')));

//ST Tests
testTime('*/5 * * * * *', new Date(Date.parse('2014-11-02 01:59:55')), new Date(Date.parse('2014-11-02 01:59:55')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-11-02 01:59:56')), new Date(Date.parse('2014-11-02 02:00:00')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-11-02 01:59:59')), new Date(Date.parse('2014-11-02 02:00:00')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-11-02 02:00:00')), new Date(Date.parse('2014-11-02 02:00:00')));
testTime('*/5 * * * * *', new Date(Date.parse('2014-11-02 02:00:01')), new Date(Date.parse('2014-11-02 02:00:05')));

testTime('00 00 09,21 * * *', new Date(Date.parse('2014-11-01 20:00:01')), new Date(Date.parse('2014-11-01 21:00:00')));
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-11-01 21:00:01')), new Date(Date.parse('2014-11-02 09:00:00')));
testTime('00 00 09,21 * * *', new Date(Date.parse('2014-11-02 01:59:59')), new Date(Date.parse('2014-11-02 09:00:00')));

//Leap Year Test
testTime('00 00 09,21 29 * *', new Date(Date.parse('2015-02-02 01:59:59')), new Date(Date.parse('2015-03-29 09:00:00')));
testTime('00 00 09,21 29 * *', new Date(Date.parse('2016-02-02 01:59:59')), new Date(Date.parse('2016-02-29 09:00:00')));
testTime('00 00 09,21 29 1 *', new Date(Date.parse('2015-02-02 01:59:59')), new Date(Date.parse('2016-02-29 09:00:00')));
testTime('00 00 09,21 29 1 *', new Date(Date.parse('2016-02-02 01:59:59')), new Date(Date.parse('2016-02-29 09:00:00')));
testTime('00 00 09,21 29 1 *', new Date(Date.parse('2016-02-29 21:00:01')), new Date(Date.parse('2020-02-29 09:00:00')));

```