Search code examples
fullcalendarfullcalendar-scheduler

Fullcalendar Year view (December not showed)


I need to create a view of all months in a year in fullcalendar. I've found this nice example that work except DECEMBER not appear.

https://codepen.io/webrexRavi/pen/yqMqGX

I don't understand what's wrong in the code:

views: {
   timelineCustom: {
       type: 'timeline',
       buttonText: 'Year',
       dateIncrement: { years: 1 },
       slotDuration: { months: 1 },
       visibleRange: function (currentDate) {
           return {
             start: currentDate.clone().startOf('year'),
             end: currentDate.clone().endOf("year")
           };
        }
       }
  }

Solution

  • Well just asumed the currentDate counts with months starting from zero and visible range expects a value between 1-12 for months, currentDate.clone().endOf("year") would then display until november ( december is the 11th month when counting from zero).

    If you cange it to

    currentDate.clone().endOf("year") +1;
    

    it displays december too.

    Edit: The fullcalendar documentation says following about visibleRange:

    The visibleRange object must have start/end properties that resolve to Moment values. The end moment is exclusive, just like all other places in the API.

    So if you want the range to include the last day, you have to add one day.

    currentDate.clone().endOf("year").add(1,'day');