new-exclusion-lists
parent
82eadcffaa
commit
5b83d09d5e
@ -1,11 +1,12 @@
|
||||
import moment from 'moment';
|
||||
|
||||
function isToday(date) {
|
||||
if (!date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return moment(date).isSame(moment(), 'day');
|
||||
const dateObj = (typeof date === 'object') ? date : new Date(date);
|
||||
const today = new Date();
|
||||
|
||||
return dateObj.getDate() === today.getDate() && dateObj.getMonth() === today.getMonth() && dateObj.getFullYear() === today.getFullYear();
|
||||
}
|
||||
|
||||
export default isToday;
|
||||
|
@ -1,11 +1,13 @@
|
||||
import moment from 'moment';
|
||||
|
||||
function isTomorrow(date) {
|
||||
if (!date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return moment(date).isSame(moment().add(1, 'day'), 'day');
|
||||
const dateObj = (typeof date === 'object') ? date : new Date(date);
|
||||
const today = new Date();
|
||||
const tomorrow = new Date((today.setDate(today.getDate() + 1)));
|
||||
|
||||
return dateObj.getDate() === tomorrow.getDate() && dateObj.getMonth() === tomorrow.getMonth() && dateObj.getFullYear() === tomorrow.getFullYear();
|
||||
}
|
||||
|
||||
export default isTomorrow;
|
||||
|
@ -1,11 +1,13 @@
|
||||
import moment from 'moment';
|
||||
|
||||
function isYesterday(date) {
|
||||
if (!date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return moment(date).isSame(moment().subtract(1, 'day'), 'day');
|
||||
const dateObj = (typeof date === 'object') ? date : new Date(date);
|
||||
const today = new Date();
|
||||
const yesterday = new Date((today.setDate(today.getDate() - 1)));
|
||||
|
||||
return dateObj.getDate() === yesterday.getDate() && dateObj.getMonth() === yesterday.getMonth() && dateObj.getFullYear() === yesterday.getFullYear();
|
||||
}
|
||||
|
||||
export default isYesterday;
|
||||
|
Loading…
Reference in new issue