Skip to content

Commit

Permalink
Merge pull request #457 from trothe/fr-time-within
Browse files Browse the repository at this point in the history
[FR] small fix for duration
  • Loading branch information
wanasit authored Jun 19, 2022
2 parents 73c7da8 + 195976d commit 4e02153
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/

export default class FRTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
innerPattern(): RegExp {
return new RegExp(`(?:dans|en|pour|pendant)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
return new RegExp(`(?:dans|en|pour|pendant|de)\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
}

innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
Expand Down
3 changes: 1 addition & 2 deletions src/locales/ja/parsers/JPStandardParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { findYearClosestToRef } from "../../../calculation/years";

import dayjs from "dayjs";

const PATTERN =
/(?:(?:([同今本])|((昭和|平成|令和)?([0-90-9]{1,4}|元)))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i;
const PATTERN = /(?:(?:([同今本])|((昭和|平成|令和)?([0-90-9]{1,4}|元)))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i;
const SPECIAL_YEAR_GROUP = 1;
const TYPICAL_YEAR_GROUP = 2;
const ERA_GROUP = 3;
Expand Down
7 changes: 7 additions & 0 deletions test/fr/fr_time_units_within.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ test("Test - Single Expression", function () {
expect(result.start).toBeDate(new Date(2012, 7, 10, 13, 14));
});

testSingleCase(chrono.fr, "régler une minuterie de 5 minutes", new Date(2012, 7, 10, 12, 14), (result) => {
expect(result.index).toBe(21);
expect(result.text).toBe("de 5 minutes");

expect(result.start).toBeDate(new Date(2012, 7, 10, 12, 19));
});

testSingleCase(chrono.fr, "Dans 5 minutes je vais rentrer chez moi", new Date(2012, 7, 10, 12, 14), (result) => {
expect(result.index).toBe(0);
expect(result.text).toBe("Dans 5 minutes");
Expand Down

0 comments on commit 4e02153

Please sign in to comment.