fix(date-utils): Fix isPastDate using moment

This commit is contained in:
Juan Tejada 2016-03-23 18:44:23 -07:00
parent 6b982f8975
commit 75c9b116bb

View file

@ -38,20 +38,11 @@ function midnight(momentDate, midnightHour = Hours.Midnight) {
return oclock(momentDate.hour(midnightHour))
}
function isPastDate({year, month, day}, ref) {
const refDay = ref.getDate();
const refMonth = ref.getMonth() + 1;
const refYear = ref.getFullYear();
if (refYear > year) {
return true;
}
if (refMonth > month) {
return true;
}
if (refDay > day) {
return true;
}
return false;
function isPastDate(inputDateObj, currentDate) {
const inputMoment = moment({...inputDateObj, month: inputDateObj.month - 1})
const currentMoment = moment(currentDate)
return inputMoment.isBefore(currentMoment)
}
const EnforceFutureDate = new chrono.Refiner();