react-dates
Version:
A responsive and accessible date range picker component built with React
19 lines (13 loc) • 458 B
JavaScript
import moment from 'moment';
export default function isBeforeDay(a, b) {
if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
const aYear = a.year();
const aMonth = a.month();
const bYear = b.year();
const bMonth = b.month();
const isSameYear = aYear === bYear;
const isSameMonth = aMonth === bMonth;
if (isSameYear && isSameMonth) return a.date() < b.date();
if (isSameYear) return aMonth < bMonth;
return aYear < bYear;
}