diff --git a/fecha.js b/fecha.js index 65f6490..294507b 100644 --- a/fecha.js +++ b/fecha.js @@ -232,7 +232,7 @@ dateInfo.hour = +dateInfo.hour + 12 } - if (dateInfo.timezoneOffset) { + if (dateInfo.timezoneOffset != null) { dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset; date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0)); diff --git a/fecha.spec.js b/fecha.spec.js index 341fc39..96718be 100644 --- a/fecha.spec.js +++ b/fecha.spec.js @@ -70,6 +70,10 @@ expect(fecha.parse('09:20:31 GMT-0500 (EST)', 'HH:mm:ss ZZ')).toEqual(new Date(Date.UTC(2015, 0, 1, 14, 20, 31))); }); + it('UTC timezone offset', function () { + expect(fecha.parse('09:20:31 GMT-0000 (UTC)', 'HH:mm:ss ZZ')).toEqual(new Date(Date.UTC(2015, 0, 1, 9, + 20, 31))); + }); it('invalid date', function () { expect(fecha.parse('hello', 'HH:mm:ss ZZ')).toEqual(false); }); @@ -176,4 +180,4 @@ }); }); }); -})(); \ No newline at end of file +})();