Skip to content

Commit

Permalink
🚚: Rename getDateWithoutTime to getMidnightDate for more readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Balaji Sridharan committed Nov 29, 2023
1 parent e3d65b2 commit cc49198
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function hasPreSelectionChanged(date1, date2) {
return date1 !== date2;
}

function getDateWithoutTime(date) {
function getMidnightDate(date) {
const dateWithoutTime = new Date(date);
dateWithoutTime.setHours(0, 0, 0, 0);
return dateWithoutTime;
Expand Down Expand Up @@ -599,9 +599,9 @@ export default class DatePicker extends React.Component {
const { startDate, endDate } = this.props;

const startDateWithoutTime = isDate(startDate)
? getDateWithoutTime(startDate)
? getMidnightDate(startDate)
: null;
const dateWithoutTime = isDate(date) ? getDateWithoutTime(date) : null;
const dateWithoutTime = isDate(date) ? getMidnightDate(date) : null;
if (
startDate &&
!endDate &&
Expand Down Expand Up @@ -669,8 +669,8 @@ export default class DatePicker extends React.Component {
if (noRanges) {
onChange([changedDate, null], event);
} else if (hasStartRange) {
const startDateWithoutTime = getDateWithoutTime(startDate);
const changedDateWithoutTime = getDateWithoutTime(changedDate);
const startDateWithoutTime = getMidnightDate(startDate);
const changedDateWithoutTime = getMidnightDate(changedDate);

if (isBefore(changedDateWithoutTime, startDateWithoutTime)) {
onChange([changedDate, null], event);
Expand Down

0 comments on commit cc49198

Please sign in to comment.