diff --git a/src/main.js b/src/main.js index b68a0d1..a2c2fa6 100644 --- a/src/main.js +++ b/src/main.js @@ -176,19 +176,8 @@ $.fn.fullCalendar = function(options) { if (options.theme) { element.addClass('ui-widget'); } - - if (options.year !== undefined && options.year != date.getFullYear()) { - date.setDate(1); - date.setMonth(0); - date.setFullYear(options.year); - } - if (options.month !== undefined && options.month != date.getMonth()) { - date.setDate(1); - date.setMonth(options.month); - } - if (options.date !== undefined) { - date.setDate(options.date); - } + + setYMD(date, options.year, options.month, options.date); @@ -528,15 +517,7 @@ $.fn.fullCalendar = function(options) { if (typeof year == 'object') { date = cloneDate(year); // provided 1 argument, a Date }else{ - if (year !== undefined) { - date.setFullYear(year); - } - if (month !== undefined) { - date.setMonth(month); - } - if (dateNum !== undefined) { - date.setDate(dateNum); - } + setYMD(date, year, month, dateNum); } render(); }, diff --git a/src/util.js b/src/util.js index b2ea9db..2da0345 100644 --- a/src/util.js +++ b/src/util.js @@ -96,6 +96,21 @@ function dayDiff(d1, d2) { // d1 - d2 return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS); } +function setYMD(date, y, m, d) { + if (y !== undefined && y != date.getFullYear()) { + date.setDate(1); + date.setMonth(0); + date.setFullYear(y); + } + if (m !== undefined && m != date.getMonth()) { + date.setDate(1); + date.setMonth(m); + } + if (d !== undefined) { + date.setDate(d); + } +} + /* Date Parsing diff --git a/tests/issue_429_gotoDate.html b/tests/issue_429_gotoDate.html new file mode 100644 index 0000000..16354fe --- /dev/null +++ b/tests/issue_429_gotoDate.html @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ +