mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 03:14:39 +08:00
fix(date-utils): Fix isPastDate using moment
This commit is contained in:
parent
2e860f97ec
commit
b82fccffe5
1 changed files with 5 additions and 14 deletions
|
@ -38,20 +38,11 @@ function midnight(momentDate, midnightHour = Hours.Midnight) {
|
||||||
return oclock(momentDate.hour(midnightHour))
|
return oclock(momentDate.hour(midnightHour))
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPastDate({year, month, day}, ref) {
|
function isPastDate(inputDateObj, currentDate) {
|
||||||
const refDay = ref.getDate();
|
const inputMoment = moment({...inputDateObj, month: inputDateObj.month - 1})
|
||||||
const refMonth = ref.getMonth() + 1;
|
const currentMoment = moment(currentDate)
|
||||||
const refYear = ref.getFullYear();
|
|
||||||
if (refYear > year) {
|
return inputMoment.isBefore(currentMoment)
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (refMonth > month) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (refDay > day) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnforceFutureDate = new chrono.Refiner();
|
const EnforceFutureDate = new chrono.Refiner();
|
||||||
|
|
Loading…
Add table
Reference in a new issue