Skip to content

Commit 257722f

Browse files
author
Wanasit Tanakitrungruang
committed
Fix: (en) Recognize "of" between month name and year
1 parent a857d3f commit 257722f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/locales/en/parsers/ENMonthNameParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const PATTERN = new RegExp(
1010
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
1111
`\\s*` +
1212
`(?:` +
13-
`[,-]?\\s*(${YEAR_PATTERN})?` +
13+
`(?:,|-|of)?\\s*(${YEAR_PATTERN})?` +
1414
")?" +
1515
"(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)",
1616
"i"

test/en/en_month.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ test("Test - Month-Year expression", function () {
6969
expect(result.start).toBeDate(new Date(2012, 9 - 1, 1, 12));
7070
});
7171

72+
testSingleCase(chrono, "in June of 2022", (result) => {
73+
expect(result.text).toContain("June of 2022");
74+
75+
expect(result.start).not.toBeNull();
76+
expect(result.start.get("year")).toBe(2022);
77+
expect(result.start.get("month")).toBe(6);
78+
});
79+
7280
testSingleCase(chrono, "Statement of comprehensive income for the year ended Dec. 2021", (result) => {
7381
expect(result.text).toBe("Dec. 2021");
7482

0 commit comments

Comments
 (0)