Skip to content

Commit fa472f2

Browse files
author
Wanasit Tanakitrungruang
committedJan 20, 2024
Fix: Update parse and parseDate function input in locales
1 parent b4e1d43 commit fa472f2

13 files changed

+27
-24
lines changed
 

‎src/locales/de/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
2222
export const casual = new Chrono(createCasualConfiguration());
2323
export const strict = new Chrono(createConfiguration(true));
2424

25-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
25+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
2626
return casual.parse(text, ref, option);
2727
}
2828

29-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
29+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3030
return casual.parseDate(text, ref, option);
3131
}
3232

‎src/locales/en/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export const GB = new Chrono(configuration.createCasualConfiguration(true));
3333
/**
3434
* A shortcut for en.casual.parse()
3535
*/
36-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
36+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
3737
return casual.parse(text, ref, option);
3838
}
3939

4040
/**
4141
* A shortcut for en.casual.parseDate()
4242
*/
43-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
43+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
4444
return casual.parseDate(text, ref, option);
4545
}

‎src/locales/es/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
2525
export const casual = new Chrono(createCasualConfiguration());
2626
export const strict = new Chrono(createConfiguration(true));
2727

28-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
28+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
2929
return casual.parse(text, ref, option);
3030
}
3131

32-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
32+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3333
return casual.parseDate(text, ref, option);
3434
}
3535

‎src/locales/fr/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
2828
export const casual = new Chrono(createCasualConfiguration());
2929
export const strict = new Chrono(createConfiguration(true));
3030

31-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
31+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
3232
return casual.parse(text, ref, option);
3333
}
3434

35-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
35+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3636
return casual.parseDate(text, ref, option);
3737
}
3838

‎src/locales/ja/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
1919
export const casual = new Chrono(createCasualConfiguration());
2020
export const strict = new Chrono(createConfiguration());
2121

22-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
22+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
2323
return casual.parse(text, ref, option);
2424
}
2525

26-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
26+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
2727
return casual.parseDate(text, ref, option);
2828
}
2929

‎src/locales/nl/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
3333
export const casual = new Chrono(createCasualConfiguration());
3434
export const strict = new Chrono(createConfiguration(true));
3535

36-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
36+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
3737
return casual.parse(text, ref, option);
3838
}
3939

40-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
40+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
4141
return casual.parseDate(text, ref, option);
4242
}
4343

‎src/locales/nl/parsers/NLRelativeDateFormatParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { matchAnyPattern } from "../../../utils/pattern";
77

88
const PATTERN = new RegExp(
99
`(dit|deze|(?:aan)?komend|volgend|afgelopen|vorig)e?\\s*(${matchAnyPattern(TIME_UNIT_DICTIONARY)})(?=\\s*)` +
10-
"(?=\\W|$)",
10+
"(?=\\W|$)",
1111
"i"
1212
);
1313

‎src/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { ParsingComponents } from "../../../results";
44
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
55
import { reverseTimeUnits } from "../../../utils/timeunits";
66

7-
const PATTERN = new RegExp(`(dit|deze|vorig|afgelopen|(?:aan)?komend|over|\\+|-)e?\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
7+
const PATTERN = new RegExp(
8+
`(dit|deze|vorig|afgelopen|(?:aan)?komend|over|\\+|-)e?\\s*(${TIME_UNITS_PATTERN})(?=\\W|$)`,
9+
"i"
10+
);
811

912
const PREFIX_WORD_GROUP = 1;
1013
const TIME_UNIT_WORD_GROUP = 2;

‎src/locales/pt/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
2424
export const casual = new Chrono(createCasualConfiguration());
2525
export const strict = new Chrono(createConfiguration(true));
2626

27-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
27+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
2828
return casual.parse(text, ref, option);
2929
}
3030

31-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
31+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3232
return casual.parseDate(text, ref, option);
3333
}
3434

‎src/locales/ru/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ export const strict = new Chrono(createConfiguration(true));
4040
/**
4141
* A shortcut for ru.casual.parse()
4242
*/
43-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
43+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
4444
return casual.parse(text, ref, option);
4545
}
4646

4747
/**
4848
* A shortcut for ru.casual.parseDate()
4949
*/
50-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
50+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
5151
return casual.parseDate(text, ref, option);
5252
}
5353

‎src/locales/uk/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ export function createConfiguration(strictMode: boolean): Configuration {
7878
/**
7979
* A shortcut for uk.casual.parse()
8080
*/
81-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
81+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
8282
return casual.parse(text, ref, option);
8383
}
8484

8585
/**
8686
* A shortcut for uk.casual.parseDate()
8787
*/
88-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
88+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
8989
return casual.parseDate(text, ref, option);
9090
}

‎src/locales/zh/hans/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export const hans = new Chrono(createCasualConfiguration());
2525
export const casual = new Chrono(createCasualConfiguration());
2626
export const strict = new Chrono(createConfiguration());
2727

28-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
28+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
2929
return casual.parse(text, ref, option);
3030
}
3131

32-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
32+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3333
return casual.parseDate(text, ref, option);
3434
}
3535

‎src/locales/zh/hant/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const hant = new Chrono(createCasualConfiguration());
2626
export const casual = new Chrono(createCasualConfiguration());
2727
export const strict = new Chrono(createConfiguration());
2828

29-
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
29+
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
3030
return casual.parse(text, ref, option);
3131
}
3232

33-
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
33+
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
3434
return casual.parseDate(text, ref, option);
3535
}
3636

0 commit comments

Comments
 (0)
Please sign in to comment.