Skip to content

Commit

Permalink
Fix: (en) Recognize "of" between month name and year
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanasit Tanakitrungruang committed Jan 25, 2025
1 parent a857d3f commit 257722f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/locales/en/parsers/ENMonthNameParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PATTERN = new RegExp(
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
`\\s*` +
`(?:` +
`[,-]?\\s*(${YEAR_PATTERN})?` +
`(?:,|-|of)?\\s*(${YEAR_PATTERN})?` +
")?" +
"(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)",
"i"
Expand Down
8 changes: 8 additions & 0 deletions test/en/en_month.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ test("Test - Month-Year expression", function () {
expect(result.start).toBeDate(new Date(2012, 9 - 1, 1, 12));
});

testSingleCase(chrono, "in June of 2022", (result) => {
expect(result.text).toContain("June of 2022");

expect(result.start).not.toBeNull();
expect(result.start.get("year")).toBe(2022);
expect(result.start.get("month")).toBe(6);
});

testSingleCase(chrono, "Statement of comprehensive income for the year ended Dec. 2021", (result) => {
expect(result.text).toBe("Dec. 2021");

Expand Down

0 comments on commit 257722f

Please sign in to comment.