diff --git a/projects/datetime-picker/src/lib/core/date-adapter.ts b/projects/datetime-picker/src/lib/core/date-adapter.ts index d8084737..54423333 100644 --- a/projects/datetime-picker/src/lib/core/date-adapter.ts +++ b/projects/datetime-picker/src/lib/core/date-adapter.ts @@ -57,8 +57,8 @@ export abstract class NgxMatDateAdapter extends DateAdapter { /** * Copy time from a date to a another date - * @param toDate - * @param fromDate + * @param toDate + * @param fromDate */ copyTime(toDate: D, fromDate: D) { this.setHour(toDate, this.getHour(fromDate)); @@ -83,6 +83,16 @@ export abstract class NgxMatDateAdapter extends DateAdapter { return res; } + /** + * Compares two dates and returns whether they are the same or not. + * @param first The first date to compare. + * @param second The second date to compare. + * @returns true if the dates are equal, false if they are not equal + */ + sameDateWithTime(first: D, second: D): boolean { + return this.compareDateWithTime(first, second, true) === 0; + } + /** * Set time by using default values * @param defaultTime List default values [hour, minute, second] diff --git a/projects/datetime-picker/src/lib/date-range-input.ts b/projects/datetime-picker/src/lib/date-range-input.ts index 6506cc1f..09c69a76 100644 --- a/projects/datetime-picker/src/lib/date-range-input.ts +++ b/projects/datetime-picker/src/lib/date-range-input.ts @@ -165,7 +165,7 @@ export class NgxMatDateRangeInput set min(value: D | null) { const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)); - if (!this._dateAdapter.sameDate(validValue, this._min)) { + if (!this._dateAdapter.sameDateWithTime(validValue, this._min)) { this._min = validValue; this._revalidate(); } @@ -180,7 +180,7 @@ export class NgxMatDateRangeInput set max(value: D | null) { const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)); - if (!this._dateAdapter.sameDate(validValue, this._max)) { + if (!this._dateAdapter.sameDateWithTime(validValue, this._max)) { this._max = validValue; this._revalidate(); } diff --git a/projects/datetime-picker/src/lib/datepicker-input.ts b/projects/datetime-picker/src/lib/datepicker-input.ts index c01a172c..b60d0a4d 100644 --- a/projects/datetime-picker/src/lib/datepicker-input.ts +++ b/projects/datetime-picker/src/lib/datepicker-input.ts @@ -75,7 +75,7 @@ export class NgxMatDatepickerInput set min(value: D | null) { const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)); - if (!this._dateAdapter.sameDate(validValue, this._min)) { + if (!this._dateAdapter.sameDateWithTime(validValue, this._min)) { this._min = validValue; this._validatorOnChange(); } @@ -90,7 +90,7 @@ export class NgxMatDatepickerInput set max(value: D | null) { const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)); - if (!this._dateAdapter.sameDate(validValue, this._max)) { + if (!this._dateAdapter.sameDateWithTime(validValue, this._max)) { this._max = validValue; this._validatorOnChange(); }