mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-15 20:48:01 +08:00
fix(date-utils): Fix isPastDate using moment
This commit is contained in:
parent
6b982f8975
commit
75c9b116bb
1 changed files with 5 additions and 14 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue