Skip to content

Commit f95856e

Browse files
committed
fix for incorrect date calcs from pull/218
1 parent 2fa6ab4 commit f95856e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/dateinput/dateinput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@
508508
// month selector
509509
monthSelector.empty();
510510
$.each(labels.months, function(i, m) {
511-
if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) {
511+
if (min < new Date(year, i + 1, 1) && max > new Date(year, i, 0)) {
512512
monthSelector.append($("<option/>").html(m).attr("value", i));
513513
}
514514
});
@@ -518,7 +518,7 @@
518518
var yearNow = now.getFullYear();
519519

520520
for (var i = yearNow + conf.yearRange[0]; i < yearNow + conf.yearRange[1]; i++) {
521-
if (min <= new Date(i + 1, -1, 1) && max > new Date(i, 0, 0)) {
521+
if (min < new Date(i + 1, 0, 1) && max > new Date(i, 0, 0)) {
522522
yearSelector.append($("<option/>").text(i));
523523
}
524524
}

test/dateinput/setmin.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- HTML5 date input -->
88
<input type="date" name="mydate" data-value="2010-12-01" min="2010-12-01" max="2011-12-02" />
99

10-
<input type="date" name="mydate" data-value="2010-12-01" min="2010-12-01" max="2012-07-01" />
10+
<input type="date" name="mydate" data-value="2010-12-30" min="2010-12-30" max="2012-07-01" />
1111

1212
<!-- make it happen -->
1313
<script>

0 commit comments

Comments
 (0)