fix(date-utils): Update semantics of 'Tonight'

- If it is past 8pm, it will snooze until midnight
This commit is contained in:
Juan Tejada 2016-02-25 11:55:22 -08:00
parent 265eb2d4e9
commit 3e67d0b451

View file

@ -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)
}, },