fixed issue 429

This commit is contained in:
Adam Shaw 2010-07-03 16:15:34 -07:00
parent 5f59997cf7
commit c002cef649
3 changed files with 62 additions and 22 deletions

View file

@ -177,18 +177,7 @@ $.fn.fullCalendar = function(options) {
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();
},

View file

@ -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

View file

@ -0,0 +1,44 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel='stylesheet' type='text/css' href='../examples/redmond/theme.css' />
<script type='text/javascript' src='loader.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
},
year: 2015,
month: 0,
date: 31
});
});
</script>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 13px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<button onclick="$('#calendar').fullCalendar('gotoDate', 2015, 1)">gotoDate - feb 2015</button>
<div id='calendar'></div>
</body>
</html>