Skip to content

Commit

Permalink
Fix: Update parse and parseDate function input in locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanasit Tanakitrungruang committed Jan 20, 2024
1 parent b4e1d43 commit fa472f2
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/locales/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration(true));

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export const GB = new Chrono(configuration.createCasualConfiguration(true));
/**
* A shortcut for en.casual.parse()
*/
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
return casual.parse(text, ref, option);
}

/**
* A shortcut for en.casual.parseDate()
*/
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}
4 changes: 2 additions & 2 deletions src/locales/es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration(true));

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration(true));

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/ja/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration());

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/nl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration(true));

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
2 changes: 1 addition & 1 deletion src/locales/nl/parsers/NLRelativeDateFormatParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { matchAnyPattern } from "../../../utils/pattern";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { ParsingComponents } from "../../../results";
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
import { reverseTimeUnits } from "../../../utils/timeunits";

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

const PREFIX_WORD_GROUP = 1;
const TIME_UNIT_WORD_GROUP = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/locales/pt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export { Component, ParsedResult, ParsingOption, ParsingReference, Meridiem, Wee
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration(true));

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/ru/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export const strict = new Chrono(createConfiguration(true));
/**
* A shortcut for ru.casual.parse()
*/
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
return casual.parse(text, ref, option);
}

/**
* A shortcut for ru.casual.parseDate()
*/
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/uk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export function createConfiguration(strictMode: boolean): Configuration {
/**
* A shortcut for uk.casual.parse()
*/
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
export function parse(text: string, ref?: ParsingReference | Date, option?: ParsingOption): ParsedResult[] {
return casual.parse(text, ref, option);
}

/**
* A shortcut for uk.casual.parseDate()
*/
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}
4 changes: 2 additions & 2 deletions src/locales/zh/hans/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export const hans = new Chrono(createCasualConfiguration());
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration());

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down
4 changes: 2 additions & 2 deletions src/locales/zh/hant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export const hant = new Chrono(createCasualConfiguration());
export const casual = new Chrono(createCasualConfiguration());
export const strict = new Chrono(createConfiguration());

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

export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
export function parseDate(text: string, ref?: ParsingReference | Date, option?: ParsingOption): Date {
return casual.parseDate(text, ref, option);
}

Expand Down

0 comments on commit fa472f2

Please sign in to comment.