Skip to content

Commit

Permalink
Better support for min/max date
Browse files Browse the repository at this point in the history
  • Loading branch information
owenmead committed Feb 3, 2015
1 parent 4b4a322 commit 098c962
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pikaday.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,14 +1066,19 @@
after -= 7;
}
cells += 7 - after;

// Ensure we only compare date portion when deciding to show a date in picker
var minDate_date = new Date(opts.minDate.getFullYear(), opts.minDate.getMonth(), opts.minDate.getDate()),

This comment has been minimized.

Copy link
@duckysherwood

duckysherwood Feb 3, 2015

minDate and maxDate can easily be false here.

maxDate_date = new Date(opts.maxDate.getFullYear(), opts.maxDate.getMonth(), opts.maxDate.getDate());

for (var i = 0, r = 0; i < cells; i++)
{
var day = new Date(year, month, 1 + (i - before)),
isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
isToday = compareDates(day, now),
isEmpty = i < before || i >= (days + before),
isDisabled = (opts.minDate && day < opts.minDate) ||
(opts.maxDate && day > opts.maxDate) ||
isDisabled = (minDate_date && day < minDate_date) ||
(maxDate_date && day > maxDate_date) ||
(opts.disableWeekends && isWeekend(day)) ||
(opts.disableDayFn && opts.disableDayFn(day));

Expand Down

0 comments on commit 098c962

Please sign in to comment.