Skip to content

Commit 5325489

Browse files
committed
Issue 180: setValue() can be supplied as ISO string
1 parent cf2fcfa commit 5325489

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/dateinput/dateinput.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,16 @@
463463

464464
setValue: function(year, month, day) {
465465

466+
467+
466468
var date = integer(month) >= -1 ? new Date(integer(year), integer(month), integer(day || 1)) :
467469
year || value;
468-
470+
469471
if (date < min) { date = min; }
470472
else if (date > max) { date = max; }
473+
474+
// date given as ISO string
475+
if (typeof year == 'string') { date = parseDate(year); }
471476

472477
year = date.getFullYear();
473478
month = date.getMonth();

test/dateinput/minimal.htm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
<!-- make it happen -->
1111
<script>
12-
$(":date").dateinput({
13-
selectors: true,
14-
yearRange: [-10, 10]
12+
var api = $(":date").dateinput({ selectors: true, yearRange: [-10, 10] }).data("dateinput");
1513

16-
}).data("dateinput");
14+
api.setValue('2012-10-10');
1715
</script>
1816

0 commit comments

Comments
 (0)