mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 16:26:08 +08:00
fix(date-utils): Update semantics of 'Tonight'
- If it is past 8pm, it will snooze until midnight
This commit is contained in:
parent
265eb2d4e9
commit
3e67d0b451
|
@ -49,7 +49,8 @@ chronoFuture.refiners.push(EnforceFutureDate);
|
||||||
|
|
||||||
const Hours = {
|
const Hours = {
|
||||||
Morning: 9,
|
Morning: 9,
|
||||||
Evening: 19,
|
Evening: 20,
|
||||||
|
Midnight: 24,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Days = {
|
const Days = {
|
||||||
|
@ -69,6 +70,10 @@ function evening(momentDate, eveningHour = Hours.Evening) {
|
||||||
return oclock(momentDate.hour(eveningHour))
|
return oclock(momentDate.hour(eveningHour))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function midnight(momentDate, midnightHour = Hours.Midnight) {
|
||||||
|
return oclock(momentDate.hour(midnightHour))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const DateUtils = {
|
const DateUtils = {
|
||||||
|
|
||||||
|
@ -100,7 +105,7 @@ const DateUtils = {
|
||||||
|
|
||||||
tonight(now = moment()) {
|
tonight(now = moment()) {
|
||||||
if (now.hour() >= Hours.Evening) {
|
if (now.hour() >= Hours.Evening) {
|
||||||
return DateUtils.tomorrowEvening();
|
return midnight(now);
|
||||||
}
|
}
|
||||||
return evening(now)
|
return evening(now)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue