Skip to content

Commit

Permalink
Merge 628badd into 3a25b04
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqi73 authored Apr 19, 2021
2 parents 3a25b04 + 628badd commit a1f11bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions components/core/time/candy-date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ describe('candy-date coverage supplements', () => {
expect(result[1]!.getMonth()).toEqual(now.getMonth());
expect(differenceInCalendarMonths(result[0]!.nativeDate, now)).toEqual(-1);

result = normalizeRangeValue([new CandyDate(), new CandyDate()], false, 'month', 'left');
expect(result[0]!.getMonth()).toEqual(now.getMonth());
expect(differenceInCalendarMonths(result[1]!.nativeDate, now)).toEqual(1);

result = normalizeRangeValue([new CandyDate(), new CandyDate()], false, 'month', 'right');
expect(result[0]!.getMonth()).toEqual(now.getMonth());
expect(differenceInCalendarMonths(result[1]!.nativeDate, now)).toEqual(1);

result = normalizeRangeValue([new CandyDate(), new CandyDate()], true);
expect(result[0]!.getMonth()).toEqual(now.getMonth());
expect(result[1]!.getMonth()).toEqual(now.getMonth());
Expand Down
8 changes: 6 additions & 2 deletions components/core/time/candy-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ export function normalizeRangeValue(
newStart = hasTimePicker ? end : end.add(-1, type);
newEnd = end;
} else if (start && end && !hasTimePicker) {
if (activePart === 'left') {
if (start.isSame(end, type)) {
newEnd = newStart.add(1, type);
} else {
newStart = newEnd.add(-1, type);
if (activePart === 'left') {
newEnd = newStart.add(1, type);
} else {
newStart = newEnd.add(-1, type);
}
}
}
return [newStart, newEnd];
Expand Down

0 comments on commit a1f11bd

Please sign in to comment.