Skip to content

Commit

Permalink
Speed up isSameDay
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Zhang committed Mar 31, 2017
1 parent fd4890c commit d2e2320
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/isSameDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import moment from 'moment';

export default function isSameDay(a, b) {
if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
return a.isSame(b, 'day');
// Speeding up by comparing most likely to differ unit first
return a.day() === b.day() &&
a.month() === b.month() &&
a.year() === b.year();
}

0 comments on commit d2e2320

Please sign in to comment.