Skip to content

Commit

Permalink
856: fixed Etc/GMT0 yields Invalid DateTime (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
raguljr committed May 8, 2021
1 parent 2d36a9c commit c34afb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/zones/IANAZone.js
Expand Up @@ -109,7 +109,7 @@ export default class IANAZone extends Zone {
/** @ignore */
static parseGMTOffset(specifier) {
if (specifier) {
const match = specifier.match(/^Etc\/GMT([+-]\d{1,2})$/i);
const match = specifier.match(/^Etc\/GMT(0|[+-]\d{1,2})$/i);
if (match) {
return -60 * parseInt(match[1]);
}
Expand Down
3 changes: 3 additions & 0 deletions test/zones/IANA.test.js
Expand Up @@ -33,6 +33,9 @@ test("IANAZone.isValidZone", () => {

test("IANAZone.parseGMTOffset returns a number for a valid input", () => {
expect(IANAZone.parseGMTOffset("Etc/GMT+8")).toBe(-480);
expect(IANAZone.parseGMTOffset("Etc/GMT+0")).toBe(-0);
expect(IANAZone.parseGMTOffset("Etc/GMT-0")).toBe(+0);
expect(IANAZone.parseGMTOffset("Etc/GMT0")).toBe(-0);
});

test("IANAZone.parseGMTOffset returns null for invalid input", () => {
Expand Down

0 comments on commit c34afb1

Please sign in to comment.