My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 67: Long Events that Skip Weekends
9 people starred this issue and may be notified of changes. Back to list
Status:  ExportedToGithub
Owner:  ----
Closed:  Aug 2015


Sign in to add a comment
 
Reported by laka...@gmail.com, Jul 28, 2009
I was looking for a way to render long events that span multiple weeks, but
exclude weekends so I slapped this together. It may be a little to
specialized to my scenario and perhaps not particularly useful to others,
but I figured I'd share my code all the same. I've attached my
fullcalendar.js, but here's just the code I added to the _renderEvents()
function:

	if (seg.event.weekends === false) {
		if (seg.isStart && seg.start.getDay() == 0)
			addDays(seg.start, 1, true);

		if (seg.isStart && seg.start.getDay() == 6)
			continue;

		if (seg.isEnd && seg.end.getDay() == 1)
			continue;
	}
	if (r2l) {
		if (seg.event.weekends === false) {
			left1 = seg.isEnd ?
								tr.find('td:eq(' + ((seg.end.getDay() + 5 - weekStart) % 7 * dis +
dit) + ') div.day-content div').position().left :
								tr.find('td:eq(' + ((5 - weekStart) % 7 * dis + dit) + ')
div.day-content div').position().left;
			left2 = seg.isStart ?
								tr.find('td:eq(' + ((seg.start.getDay() - weekStart + 7) % 7 * dis
+ dit) + ') div.day-content div') :
								tr.find('td:eq(' + ((1 - weekStart + 7) % 7 * dis + dit) + ')
div.day-content div');
		} else {
			left1 = seg.isEnd ?
								tr.find('td:eq(' + ((seg.end.getDay() + 6 - weekStart) % 7 * dis +
dit) + ') div.day-content div').position().left :
								tbody.position().left;
			left2 = seg.isStart ?
								tr.find('td:eq(' + ((seg.start.getDay() - weekStart + 7) % 7 * dis
+ dit) + ') div.day-content div') :
								tbody;
		}
		roundW = seg.isEnd;
		roundE = seg.isStart;
	} else {
		if (seg.event.weekends === false) {
			left1 = seg.isStart ?
								tr.find('td:eq(' + ((seg.start.getDay() - weekStart + 7) % 7) + ')
div.day-content div').position().left :
								tr.find('td:eq(' + ((1 - weekStart + 7) % 7) + ') div.day-content
div').position().left;
			left2 = seg.isEnd ?
								tr.find('td:eq(' + ((seg.end.getDay() + 5 - weekStart) % 7) + ')
div.day-content div') :
								tr.find('td:eq(' + ((seg.end.getDay() + 5 - weekStart) % 7) + ')
div.day-content div');
		} else {
			left1 = seg.isStart ?
								tr.find('td:eq(' + ((seg.start.getDay() - weekStart + 7) % 7) + ')
div.day-content div').position().left :
								tbody.position().left;
			left2 = seg.isEnd ?
								tr.find('td:eq(' + ((seg.end.getDay() + 6 - weekStart) % 7) + ')
div.day-content div') :
								tbody;
		}
		roundW = seg.isStart;
		roundE = seg.isEnd;
	}

To specify that an event should not span weekends simply add weekends:
false to the event definition:

	{
		id: 1,
		title: "Long Event",
		start: new Date(2009, 7, 4, 14, 0),
		end: new Date(2009, 7, 20, 11, 0),
		weekends: false
	}

@adamrshaw: If I'm doing something sloppily in the code, I'd love to know
it. I did the best I could with the information I had available.

My fullcalendar.js also appends an additional CSS class definition for
weekend days. If you add this to fullcalendar.js:

.full-calendar-month td.weekend
{
	background: #FFDFDF;
}

Weekends will be styled accordingly. This is may be a little redundant
considering each day is also given a unique class, but oh well.


fullcalendar.js
48.0 KB   View   Download
Jul 31, 2009
Project Member #1 adamrs...@gmail.com
lakario, thank you for taking the time to implement this. we've had a few other people 
request this feature (or the feature of not displaying weekends altogether). i looked 
at the code briefly, this is pretty much how i would do it. i will reference this when 
i revisit this weekend issue for 1.4 (1.3 release is pretty busy and has a lot of new 
stuff). thanks!
Aug 6, 2009
#2 zineb.me...@gmail.com
Hi adamrshaw :)
I want to congratulate you for this magnificent work you do...
I's helps me for my placement!!!
Now i'm working for the week view...I have some difficulties.
Can you tell me approximately when you can finish your 1.3 version??

Thank you a lot. 
Sep 17, 2009
#3 gle...@gmail.com
@lakario
I had a problem with your implementation, events were 1 day short.

To fix it i had to add 6 instead of 5 to left2 when seg.isEnd == true

left2 = seg.isEnd ?
									                    tr.find('td:eq(' + ((seg.end.getDay() + 6 - weekStart) %
7) + ') div.day-content div') :
									                    tr.find('td:eq(' + ((seg.end.getDay() + 5 - weekStart) %
7) + ') div.day-content div');
Sep 22, 2009
#5 laka...@gmail.com
adamrshaw:

Not sure if Google Code let's you, but you might want to re-label this issue as an
Enhancement.
Sep 22, 2009
#6 laka...@gmail.com
Here's the bug free implementation of Long Events that Skip Weekends. I also added a
tooltip (standard HTML) to all of the event titles. It's fully R2L compatible too.
This is based off of version 1.2.1 of FullCalendar.

To specify that an event should not span weekends simply add "weekends:
false" to the event definition:

{
	id: 1,
	title: "Long Event",
	start: new Date(2009, 10, 4, 14, 0),
	end: new Date(2009, 10, 20, 11, 0),
	weekends: false
}

Hope this helps you guys out!
fullcalendar.js
51.8 KB   View   Download
Sep 23, 2009
#7 gle...@gmail.com
@lakario If you implement it for v1.3 let us know.

Thanks
Sep 23, 2009
#8 laka...@gmail.com
Absolutely.

I _probably_ won't just because I built this for a client's website and it delivers
everything they're in need of. Having glanced at the 1.3 source it would be more
effort than it's worth (at least to my client). Adamrshaw did say (above) that he
intends to implement this in 1.4. Guess we'll have to see. :)
Oct 31, 2009
Project Member #9 adamrs...@gmail.com
Hello. I just released 1.4.1, which has the option to exclude weekends altogether. you 
cannot however display sat/sun while also hiding events on those days (as lakario 
described as his solution)

please take a look at the new feature and let me know if it suites your needs. if not, 
please drop a line, i'd be interested to hear why.

thanks
Nov 26, 2009
Project Member #10 adamrs...@gmail.com
hello all. im closing this issue, but respond to the thread if you have a case about
why the feature described would be better than omitting weekends altogether (which is
in 1.4.1). thanks
Status: Done
Nov 27, 2009
#11 gle...@gmail.com
The thing is not everyone uses the calendar to schedule simple events. I use it to
schedule long tasks and sometimes we want some tasks to skip weekends/holidays.

But I understand that most people don't need this functionality. Good thing the code
is open source and easy to modify :) (even tho there could be better comments)
Nov 27, 2009
Project Member #12 adamrs...@gmail.com
alright, i understand now that you may want some events to skip weekends/holidays but
others that don't. i guess i forgot the original issue and thought you wanted this
for all events (in which case hiding weekends altogether would be best), but i
understand your point of view. this could be a useful option (and like lakario
implemented, an attribute of a CalEvent object).

I see that you want it to skip weekends, but is it a requirement that it skip
holidays too? (in which case, fullcalendar would need to know some like of
locale-specific holidays)
Status: New
Labels: -Type-Defect -Priority-Medium Type-Enhancement
Oct 7, 2010
Project Member #13 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Maybe
Oct 7, 2010
#14 laka...@gmail.com
@adamrshaw I'd say skipping holidays isn't something worth concerning yourself with because holidays will vary by locale. However, perhaps a way to provide an array of excluded days for an event in addition to optionally skipping weekends would be useful.
Oct 7, 2010
Project Member #15 adamrs...@gmail.com
 Issue 620  has been merged into this issue.
Feb 10, 2011
#16 pablo....@gmail.com
anyone knows if it is already implemented?? 
Feb 10, 2011
#17 laka...@gmail.com
To the best of my knowledge, not yet.
Aug 13, 2013
Project Member #18 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Discussing
Labels: -Type-Enhancement Type-Feature
Jul 16, 2014
#19 aaronya...@gmail.com
So, sitting at version 2.0.2 this feature would really come in handy. Not sure how I could shoehorn @lakario's solution into this version. 

For background on the "why" I would like this feature. Some of the events I need to add to the calendar span 2 or 3 weeks, but only occur during the week.  I would prefer not to cut them into separate events for simplicity. I also need to add events to weekend days, so just lopping off the weekends from the calendar doesn't work. 

Any thoughts on this would be appreciated, or if I'm missing the point just slap me upside the head.
Mar 10, 2015
#20 tray...@gmail.com
Would also appreciate a function like this - I also have difficulties merging @lakario's solution into 2.3.0 and no idea where to start. Especially because I'm using angularjs (http://angular-ui.github.io/ui-calendar/)
Mar 11, 2015
#21 gsures...@gmail.com
@adamrshaw, is this solution available in 2.3.0 version
Aug 21, 2015
Project Member #22 adamrs...@gmail.com
Discussion for this issue has moved to the following URL:
https://github.com/fullcalendar/fullcalendar/issues/338

This is because Google Code is shutting down. Apologies if you are being pestered with these notifications. This is a one-time event.

Happy coding,
Adam
Status: ExportedToGithub
Sign in to add a comment

Powered by Google Project Hosting