question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Long Events that Skip Weekends

See original GitHub issue

Originally reported on Google Code with ID 67

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.


Reported by lakario on 2009-07-29 00:04:09


- _Attachment: [fullcalendar.js](https://storage.googleapis.com/google-code-attachments/fullcalendar/issue-67/comment-0/fullcalendar.js)_

Imported with 9 stars.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:5
  • Comments:33 (21 by maintainers)

github_iconTop GitHub Comments

7reactions
arshawcommented, Jun 8, 2016

if an event is split by a weekend, my knee jerk reaction is to use two separate events to represent it, one before the weekend and one after. but this might be cumbersome for some. i’ll propose a new setting:

eventExclude: 'weekends', [ 0-6 ], [ date ]

this setting will allow skipping of weekends or days-of-week or arbitrary dates.

5reactions
kennlebucommented, Nov 23, 2018

Over 3 years later, anyone got a solution? Or better, was this implemented?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a recurring event that doesn't repeat ... - Karenapp
Under the 'Doesn't repeat' option, click the downward arrow to open the drop down list. Choose the option 'Every Weekday (Monday to Friday)....
Read more >
iCal repeat events exclude weekends - Apple Community
It sounds like you want an event to repeat every 4 days but exclude weekends.
Read more >
How can I set my event duration to omit weekends?
I use google calendar to keep an eye on general project timelines. For example, I have three events that run for about 2-3...
Read more >
Skipping weekends and splitting days with an event block of 3 ...
Hi @Ryley The event should be 3 days long. Just split from friday-Monday-Tuesday. With it avoiding the weekends. Thanks again for the assistance ......
Read more >
How to create a meeting recurring every other day excluding ...
To create a recurring meeting which repeats every other day but excludes weekends in Outlook, please do as follows: 1. In the Calendar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found