From 864f498f2e47df684f099eea079edeb4e63e3e14 Mon Sep 17 00:00:00 2001 From: John Arnold Date: Tue, 18 Aug 2015 22:38:29 -0500 Subject: [PATCH 1/2] Fix for the start date of the range to allow it to contain a time. --- dist/calendar/CalendarMonth.js | 15 ++++++++++++--- src/calendar/CalendarMonth.jsx | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/dist/calendar/CalendarMonth.js b/dist/calendar/CalendarMonth.js index 89bcd2e1..a8137ff8 100644 --- a/dist/calendar/CalendarMonth.js +++ b/dist/calendar/CalendarMonth.js @@ -86,15 +86,24 @@ var CalendarMonth = _reactAddons2['default'].createClass({ var isSelectedRangeStart = undefined; var isSelectedRangeEnd = undefined; - if (!hideSelection && value && _moment2['default'].isMoment(value) && value.isSame(d, 'day')) { - isSelectedDate = true; - } else if (!hideSelection && value && (0, _utilsIsMomentRange2['default'])(value) && value.contains(d)) { + function checkRange() { isInSelectedRange = true; isSelectedRangeStart = value.start.isSame(d, 'day'); isSelectedRangeEnd = value.end.isSame(d, 'day'); } + if (!hideSelection && value && _moment2['default'].isMoment(value) && value.isSame(d, 'day')) { + isSelectedDate = true; + } else if (!hideSelection && value && (0, _utilsIsMomentRange2['default'])(value)) { + if (value.contains(d)) + { + checkRange(); + } else if (value.start.isSame(d, 'day')) { + checkRange(); + } + } + return _reactAddons2['default'].createElement(CalendarDate, _extends({ key: i, isToday: d.isSame((0, _moment2['default'])(), 'day'), diff --git a/src/calendar/CalendarMonth.jsx b/src/calendar/CalendarMonth.jsx index 5503f5ab..0b036a30 100644 --- a/src/calendar/CalendarMonth.jsx +++ b/src/calendar/CalendarMonth.jsx @@ -41,15 +41,24 @@ const CalendarMonth = React.createClass({ let isSelectedRangeStart; let isSelectedRangeEnd; - if (!hideSelection && value && moment.isMoment(value) && value.isSame(d, 'day')) { - isSelectedDate = true; - } else if (!hideSelection && value && isMomentRange(value) && value.contains(d)) { + function checkRange() { isInSelectedRange = true; isSelectedRangeStart = value.start.isSame(d, 'day'); isSelectedRangeEnd = value.end.isSame(d, 'day'); } + if (!hideSelection && value && moment.isMoment(value) && value.isSame(d, 'day')) { + isSelectedDate = true; + } else if (!hideSelection && value && isMomentRange(value)) { + if (value.contains(d)) + { + checkRange(); + } else if (value.start.isSame(d, 'day')) { + checkRange(); + } + } + return ( Date: Tue, 18 Aug 2015 22:48:16 -0500 Subject: [PATCH 2/2] Formatting. --- dist/calendar/CalendarMonth.js | 3 +-- src/calendar/CalendarMonth.jsx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dist/calendar/CalendarMonth.js b/dist/calendar/CalendarMonth.js index a8137ff8..4e3aa741 100644 --- a/dist/calendar/CalendarMonth.js +++ b/dist/calendar/CalendarMonth.js @@ -96,8 +96,7 @@ var CalendarMonth = _reactAddons2['default'].createClass({ if (!hideSelection && value && _moment2['default'].isMoment(value) && value.isSame(d, 'day')) { isSelectedDate = true; } else if (!hideSelection && value && (0, _utilsIsMomentRange2['default'])(value)) { - if (value.contains(d)) - { + if (value.contains(d)) { checkRange(); } else if (value.start.isSame(d, 'day')) { checkRange(); diff --git a/src/calendar/CalendarMonth.jsx b/src/calendar/CalendarMonth.jsx index 0b036a30..7fef3518 100644 --- a/src/calendar/CalendarMonth.jsx +++ b/src/calendar/CalendarMonth.jsx @@ -51,8 +51,7 @@ const CalendarMonth = React.createClass({ if (!hideSelection && value && moment.isMoment(value) && value.isSame(d, 'day')) { isSelectedDate = true; } else if (!hideSelection && value && isMomentRange(value)) { - if (value.contains(d)) - { + if (value.contains(d)) { checkRange(); } else if (value.start.isSame(d, 'day')) { checkRange();