Adam Shaw 16 rokov pred
rodič
commit
23d99323cc
16 zmenil súbory, kde vykonal 247 pridanie a 156 odobranie
  1. 8 0
      changelog.txt
  2. 20 1
      docs/google-calendar.txt
  3. 3 0
      docs/index.txt
  4. 37 10
      src/agenda.js
  5. 41 40
      src/gcal.js
  6. 76 20
      src/grid.js
  7. 9 4
      src/main.js
  8. 17 0
      src/util.js
  9. 1 1
      tests/default.html
  10. 13 75
      tests/gcal.html
  11. 1 0
      tests/locale.html
  12. 1 0
      tests/methods.html
  13. 12 3
      tests/options.html
  14. 1 0
      tests/theming.html
  15. 6 1
      tests/triggers.html
  16. 1 1
      version.txt

+ 8 - 0
changelog.txt

@@ -1,4 +1,12 @@
 
 
+version 1.4.1 (10/31/09)
+	- can exclude weekends with new 'weekends' option
+	- gcal feed 'currentTimezone' option
+	- bugfixes
+		- year/month/date option sometimes wouldn't set correctly (depending on current date)
+		- daylight savings issue caused agenda views to start at 1am (for BST users)
+	- cleanup of gcal.js code
+
 version 1.4 (10/19/09)
 version 1.4 (10/19/09)
 	- agendaWeek and agendaDay views
 	- agendaWeek and agendaDay views
 	- added some options for agenda views:
 	- added some options for agenda views:

+ 20 - 1
docs/google-calendar.txt

@@ -45,5 +45,24 @@ Here is a list of available options:
 * **className** - CSS class to attach to each event from this Google Calendar
 * **className** - CSS class to attach to each event from this Google Calendar
 
 
 * **editable** - whether to allow dragging/resizing (default: ``false``)
 * **editable** - whether to allow dragging/resizing (default: ``false``)
+
+* **currentTimezone** - a string like "America/Chicago". Consult http://php.net/manual/en/timezones.php for a full list.
    
    
-See *gcal.html* in the *examples* directory for a complete example.
+See *gcal.html* in the *examples* directory for a complete example.
+
+
+Timezones Gotchas
+-----------------
+
+Sometimes it can be confusing as to why FullCalendar displays event times differently
+than the Google Calendar interface. There are the two factors involved in this:
+
+* **the calendar's timezone**, accessed through "Calendar settings" after clicking the arrow next to the calendar's name
+
+* **your Google Account's timezone**, accessed through the "Settings" link at the top right
+  of the Google Calendar screen (near the "Sign out" link)
+
+When both timezones are the same, you should have no problems. When they are different, FullCalendar will display
+times in the *calendar's* timezone. Thus, times will be different than what you see in the Google Calendar interface
+because they are being adjusted to the GMT of the calendar. The solution is to use the ``currentTimezone`` option.
+If this is set to the same timezone as your Google Account, all dates should appear consistent.

+ 3 - 0
docs/index.txt

@@ -81,6 +81,9 @@ Basic Options
 **allDayDefault**: Boolean, *Default*: ``true``
 **allDayDefault**: Boolean, *Default*: ``true``
 	Determines the default value for each :ref:`CalEvent's <CalEvent>` ``allDay`` property,
 	Determines the default value for each :ref:`CalEvent's <CalEvent>` ``allDay`` property,
 	when it is unspecified.
 	when it is unspecified.
+	
+**weekends**: Boolean, *Default*: ``true``
+	Whether to include Saturday/Sunday columns in any of the views.
 
 
 **weekMode**: String, *Default*: ``'fixed'``
 **weekMode**: String, *Default*: ``'fixed'``
 	Determines the number of weeks displayed in a month view.
 	Determines the number of weeks displayed in a month view.

+ 37 - 10
src/agenda.js

@@ -23,13 +23,23 @@ views.agendaWeek = function(element, options) {
 			if (delta) {
 			if (delta) {
 				addDays(date, delta * 7);
 				addDays(date, delta * 7);
 			}
 			}
+			var visStart = this.visStart = cloneDate(
+					this.start = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7))
+				),
+				visEnd = this.visEnd = cloneDate(
+					this.end = addDays(cloneDate(visStart), 7)
+				);
+			if (!options.weekends) {
+				skipWeekend(visStart);
+				skipWeekend(visEnd, -1, true);
+			}
 			this.title = formatDates(
 			this.title = formatDates(
-				this.start = this.visStart = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7)),
-				addDays(cloneDate(this.end = this.visEnd = addDays(cloneDate(this.start), 7)), -1),
+				visStart,
+				addDays(cloneDate(visEnd), -1),
 				this.option('titleFormat'),
 				this.option('titleFormat'),
 				options
 				options
 			);
 			);
-			this.renderAgenda(7, this.option('columnFormat'), fetchEvents);
+			this.renderAgenda(options.weekends ? 7 : 5, this.option('columnFormat'), fetchEvents);
 		}
 		}
 	});
 	});
 };
 };
@@ -39,6 +49,9 @@ views.agendaDay = function(element, options) {
 		render: function(date, delta, fetchEvents) {
 		render: function(date, delta, fetchEvents) {
 			if (delta) {
 			if (delta) {
 				addDays(date, delta);
 				addDays(date, delta);
+				if (!options.weekends) {
+					skipWeekend(date, delta < 0 ? -1 : 1);
+				}
 			}
 			}
 			this.title = formatDate(date, this.option('titleFormat'), options);
 			this.title = formatDate(date, this.option('titleFormat'), options);
 			this.start = this.visStart = cloneDate(date, true);
 			this.start = this.visStart = cloneDate(date, true);
@@ -55,6 +68,7 @@ function Agenda(element, options, methods) {
 		axisWidth, colWidth, slotHeight,
 		axisWidth, colWidth, slotHeight,
 		cachedDaySegs, cachedSlotSegs,
 		cachedDaySegs, cachedSlotSegs,
 		tm, firstDay,
 		tm, firstDay,
+		nwe,            // no weekends (int)
 		rtl, dis, dit,  // day index sign / translate
 		rtl, dis, dit,  // day index sign / translate
 		// ...
 		// ...
 		
 		
@@ -104,7 +118,8 @@ function Agenda(element, options, methods) {
 		colCnt = c;
 		colCnt = c;
 		
 		
 		// update option-derived variables
 		// update option-derived variables
-		tm = options.theme ? 'ui' : 'fc'; 
+		tm = options.theme ? 'ui' : 'fc';
+		nwe = options.weekends ? 0 : 1;
 		firstDay = options.firstDay;
 		firstDay = options.firstDay;
 		if (rtl = options.isRTL) {
 		if (rtl = options.isRTL) {
 			dis = -1;
 			dis = -1;
@@ -136,10 +151,13 @@ function Agenda(element, options, methods) {
 					tm + '-state-default' +
 					tm + '-state-default' +
 					"'>" + formatDate(d, colFormat, options) + "</th>";
 					"'>" + formatDate(d, colFormat, options) + "</th>";
 				addDays(d, dis);
 				addDays(d, dis);
+				if (nwe) {
+					skipWeekend(d, dis);
+				}
 			}
 			}
-			s+= "<th class='" + tm + "-state-default'>&nbsp;</th></tr>";
+			s += "<th class='" + tm + "-state-default'>&nbsp;</th></tr>";
 			if (options.allDaySlot) {
 			if (options.allDaySlot) {
-				s+= "<tr class='fc-all-day'>" +
+				s += "<tr class='fc-all-day'>" +
 						"<th class='fc-axis fc-leftmost " + tm + "-state-default'>" + options.allDayText + "</th>" +
 						"<th class='fc-axis fc-leftmost " + tm + "-state-default'>" + options.allDayText + "</th>" +
 						"<td colspan='" + colCnt + "' class='" + tm + "-state-default'>" +
 						"<td colspan='" + colCnt + "' class='" + tm + "-state-default'>" +
 							"<div class='fc-day-content'><div>&nbsp;</div></div></td>" +
 							"<div class='fc-day-content'><div>&nbsp;</div></div></td>" +
@@ -152,7 +170,7 @@ function Agenda(element, options, methods) {
 			head.find('td').click(slotClick);
 			head.find('td').click(slotClick);
 			
 			
 			// body
 			// body
-			d = new Date(1970, 0, 1);
+			d = zeroDate();
 			s = "<table>";
 			s = "<table>";
 			for (i=0; d.getDate() != 2; i++) {
 			for (i=0; d.getDate() != 2; i++) {
 				minutes = d.getMinutes();
 				minutes = d.getMinutes();
@@ -183,6 +201,9 @@ function Agenda(element, options, methods) {
 					(+d == +today ? tm + '-state-highlight fc-today' : 'fc-not-today') +
 					(+d == +today ? tm + '-state-highlight fc-today' : 'fc-not-today') +
 					"'><div class='fc-day-content'><div>&nbsp;</div></div></td>";
 					"'><div class='fc-day-content'><div>&nbsp;</div></div></td>";
 				addDays(d, dis);
 				addDays(d, dis);
+				if (nwe) {
+					skipWeekend(d, dis);
+				}
 			}
 			}
 			s += "</tr></table></div>";
 			s += "</tr></table></div>";
 			bg = $(s).appendTo(element);
 			bg = $(s).appendTo(element);
@@ -196,6 +217,9 @@ function Agenda(element, options, methods) {
 				$(this).text(formatDate(d, colFormat, options));
 				$(this).text(formatDate(d, colFormat, options));
 				this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 				this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 				addDays(d, dis);
 				addDays(d, dis);
+				if (nwe) {
+					skipWeekend(d, dis);
+				}
 			});
 			});
 			
 			
 			// change classes of background stripes
 			// change classes of background stripes
@@ -214,6 +238,9 @@ function Agenda(element, options, methods) {
 						.removeClass(tm + '-state-highlight');
 						.removeClass(tm + '-state-highlight');
 				}
 				}
 				addDays(d, dis);
 				addDays(d, dis);
+				if (nwe) {
+					skipWeekend(d, dis);
+				}
 			});
 			});
 		
 		
 		}
 		}
@@ -226,7 +253,7 @@ function Agenda(element, options, methods) {
 	
 	
 	
 	
 	function resetScroll() {
 	function resetScroll() {
-		var d0 = new Date(1970, 0, 1),
+		var d0 = zeroDate(),
 			scrollDate = cloneDate(d0);
 			scrollDate = cloneDate(d0);
 		scrollDate.setHours(options.firstHour);
 		scrollDate.setHours(options.firstHour);
 		var go = function() {
 		var go = function() {
@@ -394,13 +421,13 @@ function Agenda(element, options, methods) {
 					}
 					}
 					if (leftRounded) {
 					if (leftRounded) {
 						className += 'fc-corner-left ';
 						className += 'fc-corner-left ';
-						left = bg.find('td:eq('+(((leftDay-firstDay+colCnt)%colCnt)*dis+dit)+') div div').position().left + axisWidth;
+						left = bg.find('td:eq('+(((leftDay-Math.max(firstDay,nwe)+colCnt)%colCnt)*dis+dit)+') div div').position().left + axisWidth;
 					}else{
 					}else{
 						left = axisWidth;
 						left = axisWidth;
 					}
 					}
 					if (rightRounded) {
 					if (rightRounded) {
 						className += 'fc-corner-right ';
 						className += 'fc-corner-right ';
-						right = bg.find('td:eq('+(((rightDay-firstDay+colCnt)%colCnt)*dis+dit)+') div div');
+						right = bg.find('td:eq('+(((rightDay-Math.max(firstDay,nwe)+colCnt)%colCnt)*dis+dit)+') div div');
 						right = right.position().left + right.width() + axisWidth;
 						right = right.position().left + right.width() + axisWidth;
 					}else{
 					}else{
 						right = axisWidth + bg.width();
 						right = axisWidth + bg.width();

+ 41 - 40
src/gcal.js

@@ -16,49 +16,50 @@
 		options = options || {};
 		options = options || {};
 		
 		
 		return function(start, end, callback) {
 		return function(start, end, callback) {
-			$.getJSON(feedUrl + "?alt=json-in-script&callback=?",
-				{
-					'start-min': $.fullCalendar.formatDate(start, 'u'),
-					'start-max': $.fullCalendar.formatDate(end, 'u'),
-					'singleevents': true,
-					'max-results': 9999
-				},
-				function(data) {
-					var events = [];
-					if (data.feed.entry) {
-						$.each(data.feed.entry, function(i, entry) {
-							var startStr = entry['gd$when'][0]['startTime'],
-								start = $.fullCalendar.parseDate(startStr),
-								end = $.fullCalendar.parseDate(entry['gd$when'][0]['endTime']),
-								allDay = startStr.indexOf('T') == -1,
-								classNames = [],
-								url;
-							$.each(entry.link, function() {
-								if (this.type == 'text/html') {
-									url = this.href;
-								}
-							});
-							if (allDay) {
-								end = new Date(end - 1); // make inclusive
+			var params = {
+				'start-min': $.fullCalendar.formatDate(start, 'u'),
+				'start-max': $.fullCalendar.formatDate(end, 'u'),
+				'singleevents': true,
+				'max-results': 9999
+			};
+			if (options.currentTimezone) {
+				params.ctz = options.currentTimezone.replace(' ', '_');
+			}
+			$.getJSON(feedUrl + "?alt=json-in-script&callback=?", params, function(data) {
+				var events = [];
+				if (data.feed.entry) {
+					$.each(data.feed.entry, function(i, entry) {
+						var startStr = entry['gd$when'][0]['startTime'],
+							start = $.fullCalendar.parseISO8601(startStr, true),
+							end = $.fullCalendar.parseISO8601(entry['gd$when'][0]['endTime'], true),
+							allDay = startStr.indexOf('T') == -1,
+							url;
+						$.each(entry.link, function() {
+							if (this.type == 'text/html') {
+								url = this.href;
 							}
 							}
-							events.push({
-								id: entry['gCal$uid']['value'],
-								title: entry['title']['$t'],
-								url: url,
-								start: $.fullCalendar.parseDate(entry['gd$when'][0]['startTime']),
-								end: end,
-								allDay: allDay,
-								location: entry['gd$where'][0]['valueString'],
-								description: entry['content']['$t'],
-								className: options.className,
-								editable: options.editable || false
-							});
 						});
 						});
-					}
-					callback(events);
-				});
+						if (allDay) {
+							$.fullCalendar.addDays(end, -1); // make inclusive
+						}
+						events.push({
+							id: entry['gCal$uid']['value'],
+							title: entry['title']['$t'],
+							url: url,
+							start: start,
+							end: end,
+							allDay: allDay,
+							location: entry['gd$where'][0]['valueString'],
+							description: entry['content']['$t'],
+							className: options.className,
+							editable: options.editable || false
+						});
+					});
+				}
+				callback(events);
+			});
 		}
 		}
 		
 		
 	}
 	}
 
 
-})(jQuery);
+})(jQuery);

+ 76 - 20
src/grid.js

@@ -13,22 +13,39 @@ views.month = function(element, options) {
 				addMonths(date, delta);
 				addMonths(date, delta);
 				date.setDate(1);
 				date.setDate(1);
 			}
 			}
+			// start/end
 			var start = this.start = cloneDate(date, true);
 			var start = this.start = cloneDate(date, true);
 			start.setDate(1);
 			start.setDate(1);
-			this.title = formatDates(
+			this.end = addMonths(cloneDate(start), 1);
+			// visStart/visEnd
+			var visStart = this.visStart = cloneDate(start),
+				visEnd = this.visEnd = cloneDate(this.end),
+				nwe = options.weekends ? 0 : 1;
+			if (nwe) {
+				skipWeekend(visStart);
+				skipWeekend(visEnd, -1, true);
+			}
+			addDays(visStart, -((visStart.getDay() - Math.max(options.firstDay, nwe) + 7) % 7));
+			addDays(visEnd, (7 - visEnd.getDay() + Math.max(options.firstDay, nwe)) % 7);
+			// row count
+			var rowCnt = Math.round((visEnd - visStart) / (DAY_MS * 7));
+			if (options.weekMode == 'fixed') {
+				addDays(visEnd, (6 - rowCnt) * 7);
+				rowCnt = 6;
+			}
+			// title
+			this.title = formatDate(
 				start,
 				start,
-				addDays(cloneDate(this.end = addMonths(cloneDate(start), 1)), -1),
 				this.option('titleFormat'),
 				this.option('titleFormat'),
 				options
 				options
 			);
 			);
-			addDays(this.visStart = cloneDate(start), -((start.getDay() - options.firstDay + 7) % 7));
-			addDays(this.visEnd = cloneDate(this.end), (7 - this.visEnd.getDay() + options.firstDay) % 7);
-			var rowCnt = Math.round((this.visEnd - this.visStart) / (DAY_MS * 7));
-			if (options.weekMode == 'fixed') {
-				addDays(this.visEnd, (6 - rowCnt) * 7);
-				rowCnt = 6;
-			}
-			this.renderGrid(rowCnt, 7, this.option('columnFormat'), true, fetchEvents);
+			// render
+			this.renderGrid(
+				rowCnt, options.weekends ? 7 : 5,
+				this.option('columnFormat'),
+				true,
+				fetchEvents
+			);
 		}
 		}
 	});
 	});
 }
 }
@@ -39,13 +56,28 @@ views.basicWeek = function(element, options) {
 			if (delta) {
 			if (delta) {
 				addDays(date, delta * 7);
 				addDays(date, delta * 7);
 			}
 			}
+			var visStart = this.visStart = cloneDate(
+					this.start = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7))
+				),
+				visEnd = this.visEnd = cloneDate(
+					this.end = addDays(cloneDate(visStart), 7)
+				);
+			if (!options.weekends) {
+				skipWeekend(visStart);
+				skipWeekend(visEnd, -1, true);
+			}
 			this.title = formatDates(
 			this.title = formatDates(
-				this.start = this.visStart = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7)),
-				addDays(cloneDate(this.end = this.visEnd = addDays(cloneDate(this.start), 7)), -1),
+				visStart,
+				addDays(cloneDate(visEnd), -1),
 				this.option('titleFormat'),
 				this.option('titleFormat'),
 				options
 				options
 			);
 			);
-			this.renderGrid(1, 7, this.option('columnFormat'), false, fetchEvents);
+			this.renderGrid(
+				1, options.weekends ? 7 : 5,
+				this.option('columnFormat'),
+				false,
+				fetchEvents
+			);
 		}
 		}
 	});
 	});
 };
 };
@@ -55,6 +87,9 @@ views.basicDay = function(element, options) {
 		render: function(date, delta, fetchEvents) {
 		render: function(date, delta, fetchEvents) {
 			if (delta) {
 			if (delta) {
 				addDays(date, delta);
 				addDays(date, delta);
+				if (!options.weekends) {
+					skipWeekend(date, delta < 0 ? -1 : 1);
+				}
 			}
 			}
 			this.title = formatDate(date, this.option('titleFormat'), options);
 			this.title = formatDate(date, this.option('titleFormat'), options);
 			this.start = this.visStart = cloneDate(date, true);
 			this.start = this.visStart = cloneDate(date, true);
@@ -73,6 +108,7 @@ var tdHeightBug, rtlLeftDiff;
 function Grid(element, options, methods) {
 function Grid(element, options, methods) {
 	
 	
 	var tm, firstDay,
 	var tm, firstDay,
+		nwe,            // no weekends (int)
 		rtl, dis, dit,  // day index sign / translate
 		rtl, dis, dit,  // day index sign / translate
 		rowCnt, colCnt,
 		rowCnt, colCnt,
 		colWidth,
 		colWidth,
@@ -115,7 +151,8 @@ function Grid(element, options, methods) {
 		colCnt = c;
 		colCnt = c;
 		
 		
 		// update option-derived variables
 		// update option-derived variables
-		tm = options.theme ? 'ui' : 'fc'; 
+		tm = options.theme ? 'ui' : 'fc';
+		nwe = options.weekends ? 0 : 1;
 		firstDay = options.firstDay;
 		firstDay = options.firstDay;
 		if (rtl = options.isRTL) {
 		if (rtl = options.isRTL) {
 			dis = -1;
 			dis = -1;
@@ -141,6 +178,9 @@ function Grid(element, options, methods) {
 					(i==dit ? ' fc-leftmost' : '') +
 					(i==dit ? ' fc-leftmost' : '') +
 					"'>" + formatDate(d, colFormat, options) + "</th>";
 					"'>" + formatDate(d, colFormat, options) + "</th>";
 				addDays(d, 1);
 				addDays(d, 1);
+				if (nwe) {
+					skipWeekend(d);
+				}
 			}
 			}
 			thead = $(s + "</tr></thead>").appendTo(table);
 			thead = $(s + "</tr></thead>").appendTo(table);
 			
 			
@@ -160,6 +200,9 @@ function Grid(element, options, methods) {
 						(showNumbers ? "<div class='fc-day-number'>" + d.getDate() + "</div>" : '') +
 						(showNumbers ? "<div class='fc-day-number'>" + d.getDate() + "</div>" : '') +
 						"<div class='fc-day-content'><div>&nbsp;</div></div></td>";
 						"<div class='fc-day-content'><div>&nbsp;</div></div></td>";
 					addDays(d, 1);
 					addDays(d, 1);
+					if (nwe) {
+						skipWeekend(d);
+					}
 				}
 				}
 				s += "</tr>";
 				s += "</tr>";
 			}
 			}
@@ -187,6 +230,9 @@ function Grid(element, options, methods) {
 							"<div class='fc-day-content'><div>&nbsp;</div></div>" +
 							"<div class='fc-day-content'><div>&nbsp;</div></div>" +
 							"</td>";
 							"</td>";
 						addDays(d, 1);
 						addDays(d, 1);
+						if (nwe) {
+							skipWeekend(d);
+						}
 					}
 					}
 					s += "</tr>";
 					s += "</tr>";
 				}
 				}
@@ -216,6 +262,9 @@ function Grid(element, options, methods) {
 				}
 				}
 				td.find('div.fc-day-number').text(d.getDate());
 				td.find('div.fc-day-number').text(d.getDate());
 				addDays(d, 1);
 				addDays(d, 1);
+				if (nwe) {
+					skipWeekend(d);
+				}
 			});
 			});
 			
 			
 			if (rowCnt == 1) { // more changes likely (week or day view)
 			if (rowCnt == 1) { // more changes likely (week or day view)
@@ -226,6 +275,9 @@ function Grid(element, options, methods) {
 					$(this).text(formatDate(d, colFormat, options));
 					$(this).text(formatDate(d, colFormat, options));
 					this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 					this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 					addDays(d, 1);
 					addDays(d, 1);
+					if (nwe) {
+						skipWeekend(d);
+					}
 				});
 				});
 				
 				
 				// redo cell day-of-weeks
 				// redo cell day-of-weeks
@@ -233,6 +285,9 @@ function Grid(element, options, methods) {
 				tbody.find('td').each(function() {
 				tbody.find('td').each(function() {
 					this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 					this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
 					addDays(d, 1);
 					addDays(d, 1);
+					if (nwe) {
+						skipWeekend(d);
+					}
 				});
 				});
 				
 				
 			}
 			}
@@ -246,10 +301,11 @@ function Grid(element, options, methods) {
 	
 	
 	
 	
 	function dayClick(ev) {
 	function dayClick(ev) {
-		var date = addDays(
-			cloneDate(view.visStart),
-			parseInt(this.className.match(/fc\-day(\d+)/)[1])
-		);
+		var n = parseInt(this.className.match(/fc\-day(\d+)/)[1]),
+			date = addDays(
+				cloneDate(view.visStart),
+				Math.floor(n/colCnt) * 7 + n % colCnt
+			);
 		view.trigger('dayClick', this, date, true, ev);
 		view.trigger('dayClick', this, date, true, ev);
 	}
 	}
 	
 	
@@ -359,10 +415,10 @@ function Grid(element, options, methods) {
 					event = seg.event;
 					event = seg.event;
 					className = 'fc-event fc-event-hori ';
 					className = 'fc-event fc-event-hori ';
 					startElm = seg.isStart ?
 					startElm = seg.isStart ?
-						tr.find('td:eq('+((seg.start.getDay()-firstDay+colCnt)%colCnt)+') div div') :
+						tr.find('td:eq('+((seg.start.getDay()-Math.max(firstDay,nwe)+colCnt)%colCnt)+') div div') :
 						tbody;
 						tbody;
 					endElm = seg.isEnd ?
 					endElm = seg.isEnd ?
-						tr.find('td:eq('+((seg.end.getDay()-firstDay+colCnt-1)%colCnt)+') div div') :
+						tr.find('td:eq('+((seg.end.getDay()-Math.max(firstDay,nwe)+colCnt-1)%colCnt)+') div div') :
 						tbody;
 						tbody;
 					if (rtl) {
 					if (rtl) {
 						left = endElm.position().left;
 						left = endElm.position().left;

+ 9 - 4
src/main.js

@@ -16,6 +16,7 @@ var defaults = {
 		center: '',
 		center: '',
 		right: 'today prev,next'
 		right: 'today prev,next'
 	},
 	},
+	weekends: true,
 	
 	
 	// editing
 	// editing
 	//editable: false,
 	//editable: false,
@@ -159,10 +160,14 @@ $.fn.fullCalendar = function(options) {
 		var date = new Date(),
 		var date = new Date(),
 			viewName, view, // the current view
 			viewName, view, // the current view
 			viewInstances = {};
 			viewInstances = {};
-		if (options.year != undefined) {
-			date.setYear(options.year);
+			
+		if (options.year != undefined && options.year != date.getFullYear()) {
+			date.setDate(1);
+			date.setMonth(0);
+			date.setFullYear(options.year);
 		}
 		}
-		if (options.month != undefined) {
+		if (options.month != undefined && options.month != date.getMonth()) {
+			date.setDate(1);
 			date.setMonth(options.month);
 			date.setMonth(options.month);
 		}
 		}
 		if (options.date != undefined) {
 		if (options.date != undefined) {
@@ -396,7 +401,7 @@ $.fn.fullCalendar = function(options) {
 					date = cloneDate(year); // provided 1 argument, a Date
 					date = cloneDate(year); // provided 1 argument, a Date
 				}else{
 				}else{
 					if (year != undefined) {
 					if (year != undefined) {
-						date.setYear(year);
+						date.setFullYear(year);
 					}
 					}
 					if (month != undefined) {
 					if (month != undefined) {
 						date.setMonth(month);
 						date.setMonth(month);

+ 17 - 0
src/util.js

@@ -47,6 +47,7 @@ function addDays(d, n, keepTime) { // deals with daylight savings
 	}
 	}
 	return d;
 	return d;
 }
 }
+fc.addDays = addDays;
 
 
 function addMinutes(d, n) {
 function addMinutes(d, n) {
 	d.setMinutes(d.getMinutes() + n);
 	d.setMinutes(d.getMinutes() + n);
@@ -68,6 +69,22 @@ function cloneDate(d, dontKeepTime) {
 	return new Date(+d);
 	return new Date(+d);
 }
 }
 
 
+function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1
+	var i=0, d;
+	do {
+		d = new Date(1970, i++, 1);
+	} while (d.getHours() != 0);
+	return d;
+}
+
+function skipWeekend(date, inc, excl) {
+	inc = inc || 1;
+	while (date.getDay()==0 || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
+		addDays(date, inc);
+	}
+	return date;
+}
+
 
 
 
 
 /* Date Parsing
 /* Date Parsing

+ 1 - 1
tests/default.html

@@ -89,4 +89,4 @@
 <body>
 <body>
 <div id='calendar'></div>
 <div id='calendar'></div>
 </body>
 </body>
-</html>
+</html>

+ 13 - 75
tests/gcal.html

@@ -4,13 +4,9 @@
 <script type='text/javascript' src='loader.js'></script>
 <script type='text/javascript' src='loader.js'></script>
 <script type='text/javascript'>
 <script type='text/javascript'>
 
 
-	var date = new Date();
-	var d = date.getDate();
-	var m = date.getMonth();
-	var y = date.getFullYear();
-
 	$(document).ready(function() {
 	$(document).ready(function() {
 		$('#calendar').fullCalendar({
 		$('#calendar').fullCalendar({
+			//weekends: false,
 			header: {
 			header: {
 				left: 'prev,next today',
 				left: 'prev,next today',
 				center: 'title',
 				center: 'title',
@@ -25,59 +21,19 @@
 						className: ['holiday']
 						className: ['holiday']
 					}
 					}
 				),
 				),
-				/*$.fullCalendar.gcalFeed(
-					"http://www.google.com/calendar/feeds/mike%40maddogsportsbar.com/private-4ad75f9427058f8fe6525c0857c59fbc/basic",
-					{
-						className: 'maddog'
-					}
-				),*/
-				[
-					{
-						title: 'All Day Event',
-						start: new Date(y, m, 1)
-					},
-					{
-						title: 'Long Event',
-						start: new Date(y, m, d-5),
-						end: new Date(y, m, d-2)
-					},
-					{
-						id: 999,
-						title: 'Repeating Event',
-						start: new Date(y, m, d-3, 16, 0),
-						allDay: false
-					},
-					{
-						id: 999,
-						title: 'Repeating Event',
-						start: new Date(y, m, d+4, 16, 0),
-						allDay: false
-					},
-					{
-						title: 'Meeting',
-						start: new Date(y, m, d, 10, 30),
-						allDay: false
-					},
-					{
-						title: 'Lunch',
-						start: new Date(y, m, d, 12, 0),
-						end: new Date(y, m, d, 14, 0),
-						allDay: false
-					},
-					{
-						title: 'Birthday Party',
-						start: new Date(y, m, d+1, 19, 0),
-						end: new Date(y, m, d+1, 22, 30),
-						allDay: false
-					},
+				$.fullCalendar.gcalFeed(
+					"http://www.google.com/calendar/feeds/b62ul6i1vvfh9vqabsal835028%40group.calendar.google.com/public/basic",
 					{
 					{
-						title: 'Click for Google',
-						start: new Date(y, m, 28),
-						end: new Date(y, m, 29),
-						url: 'http://google.com/'
+						editable: true,
+						currentTimezone: 'America/Los_Angeles' //'America/Los Angeles'
 					}
 					}
-				]
-			]
+				)
+			],
+			eventClick: function(event) {
+				console.log(event.start);
+				console.log(event.end);
+				return false;
+			}
 		});
 		});
 	});
 	});
 
 
@@ -91,28 +47,10 @@
 		border-color: green;
 		border-color: green;
 		color: yellow;
 		color: yellow;
 		}
 		}
-		
-	.maddog,
-	.maddog a {
-		background: red;
-		border-color: red;
-		}
-		
-		
-
-	/* rescued from fullcalendar.css (not used here) */
-	
-	.fc-event-nobg,
-	.fc-event-nobg a,
-	.fc-agenda .fc-event-nobg .fc-event-time {
-		border-style: none;
-		background: none;
-		color: inherit;
-		}
 
 
 </style>
 </style>
 </head>
 </head>
 <body style='font-size:12px'>
 <body style='font-size:12px'>
 <div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
 <div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
 </body>
 </body>
-</html>
+</html>

+ 1 - 0
tests/locale.html

@@ -21,6 +21,7 @@
 			
 			
 			isRTL: true,
 			isRTL: true,
 			firstDay: 1,
 			firstDay: 1,
+			//weekends: false,
 			
 			
 			monthNames: ["januari", "februari", "maart", "april", "mei", "juni","juli", "augustus", "september", "oktober", "november", "december"],
 			monthNames: ["januari", "februari", "maart", "april", "mei", "juni","juli", "augustus", "september", "oktober", "november", "december"],
 			monthNamesShort: ["jan", "feb", "maa", "apr", "mei", "jun", "jul", "aug","sep", "okt", "nov", "dec"],
 			monthNamesShort: ["jan", "feb", "maa", "apr", "mei", "jun", "jul", "aug","sep", "okt", "nov", "dec"],

+ 1 - 0
tests/methods.html

@@ -14,6 +14,7 @@
 	$(document).ready(function() {
 	$(document).ready(function() {
 		cal = $('#calendar').fullCalendar({
 		cal = $('#calendar').fullCalendar({
 			editable: true,
 			editable: true,
+			weekends: false,
 			header: {
 			header: {
 				left: 'prev,next today',
 				left: 'prev,next today',
 				center: 'title',
 				center: 'title',

+ 12 - 3
tests/options.html

@@ -16,9 +16,18 @@
 			//month: 0,
 			//month: 0,
 			//date: 1,
 			//date: 1,
 			
 			
+			/*
+			//previous bug, should NOT be march
+			year: 2009,
+			month: 1,
+			date: 15,
+			*/
+			
 			//defaultView: 'basicDay',
 			//defaultView: 'basicDay',
 			
 			
-			//aspectRatio: 1,
+			//aspectRatio: 2,
+			
+			weekends: false,
 			
 			
 			
 			
 			header: {
 			header: {
@@ -34,7 +43,7 @@
 			//dragOpacity: { agendaWeek: .1 },
 			//dragOpacity: { agendaWeek: .1 },
 			dragRevertDuration: 100,
 			dragRevertDuration: 100,
 			
 			
-			weekMode: 'variable',
+			//weekMode: 'variable',
 			
 			
 			//allDaySlot: false,
 			//allDaySlot: false,
 			allDayText: 'ALLDAY',
 			allDayText: 'ALLDAY',
@@ -114,4 +123,4 @@
 <body style='font-size:12px'>
 <body style='font-size:12px'>
 <div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
 <div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
 </body>
 </body>
-</html>
+</html>

+ 1 - 0
tests/theming.html

@@ -15,6 +15,7 @@
 		
 		
 			theme: true,
 			theme: true,
 			editable: true,
 			editable: true,
+			//weekends: false,
 			
 			
 			header: {
 			header: {
 				left: 'prevYear,prev,next,nextYear today',
 				left: 'prevYear,prev,next,nextYear today',

+ 6 - 1
tests/triggers.html

@@ -11,6 +11,8 @@
 
 
 	$(document).ready(function() {
 	$(document).ready(function() {
 		$('#calendar').fullCalendar({
 		$('#calendar').fullCalendar({
+			weekends: false,
+			
 			header: {
 			header: {
 				left: 'prev,next today',
 				left: 'prev,next today',
 				center: 'title',
 				center: 'title',
@@ -21,6 +23,8 @@
 			
 			
 			viewDisplay: function(view) {
 			viewDisplay: function(view) {
 				console.log('viewDisplay');
 				console.log('viewDisplay');
+				console.log(view.start + ' - ' + view.end);
+				console.log(view.visStart + ' - ' + view.visEnd);
 				//console.log(view);
 				//console.log(view);
 				//console.log(this);
 				//console.log(this);
 			},
 			},
@@ -33,7 +37,8 @@
 			},
 			},
 			
 			
 			dayClick: function(dayDate, allDay, ev, view) {
 			dayClick: function(dayDate, allDay, ev, view) {
-				console.log('dayClick - ' + dayDate + ', allDay:' + allDay + ' - ' + view.title);
+				alert(dayDate);
+				//console.log('dayClick - ' + dayDate + ', allDay:' + allDay + ' - ' + view.title);
 				//console.log(ev);
 				//console.log(ev);
 				//console.log(this);
 				//console.log(this);
 			},
 			},

+ 1 - 1
version.txt

@@ -1 +1 @@
-1.4
+1.4.1