Skip to content

Commit

Permalink
Merge pull request #8 from dettier/master
Browse files Browse the repository at this point in the history
Error parsing timezone +0000
  • Loading branch information
taylorhakes committed Nov 18, 2015
2 parents 090b331 + 402a24a commit 9658599
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fecha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 5 additions & 1 deletion fecha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -176,4 +180,4 @@
});
});
});
})();
})();

0 comments on commit 9658599

Please sign in to comment.