Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FullCalendar - Event spanning all day are one day too short

I'm passing to fullcalendar an event like this one:

{
     id: 31,
     title: 'Test',
     start: '2014-12-22',
     end: '2014-12-23',
     allDay: true
}

I expected to find in the calendar an event that spans two whole days, but the event is only in the 2014-12-22 slot, not in the 2014-12-23 one. The nextDayThreshold parameter is set to 00:00:00, but according to the documentation it should be ignored when allDay is set to true. I'm sure that allDay is correctly interpreted because in the agenda view the event appears in the all-day row.

How can I set fullcalendar to display such an event in both days?

like image 967
Soel Avatar asked Dec 22 '14 14:12

Soel


People also ask

How do I select multiple dates in FullCalendar?

Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.

How do I change the date on FullCalendar?

The calendar's dates can change any time the user does the following: click the prev/next buttons, change the view, click a navlink. The dates can also change when the current-date is manipulated via the API, such as when gotoDate is called. datesSet is called after the new date range has been rendered.

How do I set events in FullCalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I create a dynamic event in FullCalendar?

although it is not specified on the fullcalender site, it is necessary to assign a value to the "allday" parameter to be able to add new events dynamically. If you set this value to "false", it will not add the event to the AllDay row. If you do "true" it will add to the AllDay row. Save this answer.


2 Answers

Based on the eventDataTransform function you could add 1 day if your event is allDay. Note that this will only affect rendering.

eventDataTransform: function(event) {                                                                                                                                
  if(event.allDay) {                                                                                                                                               
    event.end = moment(event.end).add(1, 'days')                                                                                                                 
  }
  return event;  
}                                                                                                                                                  
like image 116
metakungfu Avatar answered Sep 23 '22 10:09

metakungfu


I believe this a conscious design decision, in that all end dates are to be regarded as exclusive, based on discussions like this and this, i.e. so despite being an all day event, your end date is not regarded as included (inclusive) of the dates tagged. e.g. If you have a start date of 2015-03-01 00:00:00 and an end date of 2015-03-02 00:00:00 the span is only one day.

This seems to coincide with the version 2 upgrade to using moment.js. So it would appear you will either need to add '23:59:59' to your end date, or to find a a different way of specifying the end date, e.g. as a duration of two days added to the start date?

like image 36
StuartLC Avatar answered Sep 25 '22 10:09

StuartLC