Skip to content

Commit

Permalink
FIX: Ambiguous timezone names when time is not mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanasit Tanakitrungruang committed Jan 30, 2022
1 parent 21c6496 commit afbba58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/refiners/ExtractTimezoneAbbrRefiner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ export default class ExtractTimezoneAbbrRefiner implements Refiner {
}
}

if (result.start.isOnlyDate()) {
if (timezoneAbbr != match[1]) {
return;
}
}

result.text += match[0];

if (!result.start.isCertain("timezoneOffset")) {
Expand Down
13 changes: 13 additions & 0 deletions test/en/en_month.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,16 @@ test("Test - year 90's parsing", () => {
expect(result.start.get("month")).toBe(8);
});
});

test("Test - Month should not have timezone", () => {
testSingleCase(
chrono,
"People visiting Buñol towards the end of August get a good chance to participate in La Tomatina (under normal circumstances)",
new Date(2012, 7, 10),
(result) => {
expect(result.text).toBe("August");
expect(result.start.get("year")).toBe(2012);
expect(result.start.get("month")).toBe(8);
}
);
});

0 comments on commit afbba58

Please sign in to comment.