diff --git a/index.js b/index.js index 088efe3..188497e 100644 --- a/index.js +++ b/index.js @@ -578,12 +578,14 @@ function Date (year, month, day, hour, minute, second, millisecond, timezone) { case 7: d = new _Date(year, month, day, hour, minute, second, millisecond); break; } - if (timezone) { - // set time given timezone relative to the currently set local time - // (changing the internal "time" milliseconds value unless ms specified) - d.setTimezone(timezone, !(argc == 1 && typeof year === 'number')); - } else { - d.setTimezone(exports.currentTimezone); + if (!isNaN(d)) { + if (timezone) { + // set time given timezone relative to the currently set local time + // (changing the internal "time" milliseconds value unless ms specified) + d.setTimezone(timezone, !(argc == 1 && typeof year === 'number')); + } else { + d.setTimezone(exports.currentTimezone); + } } return d; }