Skip to content

Commit

Permalink
Merge pull request #2381 from LuccaSA/fix.date.select.search
Browse files Browse the repository at this point in the history
Fix date-select search with year granularity
  • Loading branch information
jeremie-lucca committed Oct 31, 2023
2 parents 692df75 + 9db4f3a commit b66082d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/ng/core/date/native/native-date.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ export class LuNativeDateAdapter extends ALuDateAdapter<Date> implements ILuDate
return false;
}
const groups = text.split(this._regex);
if (groups.length !== 3 && groups.length !== 2) {
const dayTextInvalid = granularity === ELuDateGranularity.day && groups.length !== 3;
const monthTextInvalid = granularity === ELuDateGranularity.month && groups.length !== 2;
const yearTextInvalid = granularity === ELuDateGranularity.year && groups.length !== 1;
if (dayTextInvalid || monthTextInvalid || yearTextInvalid) {
return false;
}

try {
const { date, month, year } = this.extract(text, granularity);

// When year is greater than 10_000 ISO string goes from 2000-01-01 to +010000-01-01 which is not supported by backends
if (year > 10_000) {
// When year is equal or greater than 10_000 ISO string goes from 2000-01-01 to +010000-01-01 which is not supported by backends
if (year >= 10_000) {
return false;
}

Expand Down Expand Up @@ -123,6 +127,7 @@ export class LuNativeDateAdapter extends ALuDateAdapter<Date> implements ILuDate
if (!text) {
return undefined;
}

if (!this.isParsable(text, granularity)) {
return this.forgeInvalid();
}
Expand Down

0 comments on commit b66082d

Please sign in to comment.