@wernfried/daterangepicker 5.2.14 → 5.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1088,9 +1088,9 @@ class DateRangePicker {
1088
1088
  if (endDate < minDate) {
1089
1089
  violation = { old: endDate, reason: "minSpan" };
1090
1090
  if (this.defaultSpan) {
1091
- endDate = endDate.plus({ seconds: Math.trunc(startDate.plus(this.defaultSpan).diff(endDate).as("seconds") / shiftStep) * shiftStep });
1091
+ endDate = startDate.plus({ seconds: Math.trunc(this.defaultSpan.as("seconds") / shiftStep) * shiftStep });
1092
1092
  } else {
1093
- endDate = endDate.plus({ seconds: Math.trunc(minDate.diff(endDate).as("seconds") / shiftStep) * shiftStep });
1093
+ endDate = startDate.plus({ seconds: Math.trunc(this.minSpan.as("seconds") / shiftStep) * shiftStep });
1094
1094
  }
1095
1095
  if (endDate < minDate)
1096
1096
  endDate = endDate.plus(this.timePicker ? this.timePickerStepSize : { days: 1 });
@@ -2041,8 +2041,14 @@ class DateRangePicker {
2041
2041
  this.#startDate = this.#startDate.set({ hour, minute, second });
2042
2042
  if (this.singleDatePicker) {
2043
2043
  this.#endDate = this.#startDate;
2044
- } else if (this.#endDate && this.#endDate.hasSame(this.#startDate, "day") && this.#endDate < this.#startDate) {
2045
- this.#endDate = this.#startDate;
2044
+ } else if (this.#endDate && this.#endDate.hasSame(this.#startDate, "day")) {
2045
+ if (this.defaultSpan && this.#endDate < this.#startDate.plus(this.minSpan)) {
2046
+ this.#endDate = this.#startDate.plus(this.defaultSpan);
2047
+ } else if (this.minSpan && this.#endDate < this.#startDate.plus(this.minSpan)) {
2048
+ this.#endDate = this.#startDate.plus(this.minSpan);
2049
+ } else if (this.#endDate < this.#startDate) {
2050
+ this.#endDate = this.#startDate;
2051
+ }
2046
2052
  }
2047
2053
  } else if (this.#endDate) {
2048
2054
  this.#endDate = this.#endDate.set({ hour, minute, second });