0

does anyone know of a jquery plugin that tell you how many times to repeat an event based on the started and ended date?

I was trying to calculate it myslef, but so far luck :(

var cur_dayofweek = calEvent.start.getDay(),
    org_start_date = calEvent.start.getDate(),
    org_end_date = $( '.j-date' ).datepicker( "getDate" ).getDate(), 
    recurring = Math.round(org_end_date/org_start_date);

recurring is wrong.

Any idea of how can i get this to work or any useful plugin that i can use for it?

NOTE: I'm using jquery-week-calendar plugin

Darkagelink
  • 647
  • 1
  • 8
  • 16

2 Answers2

1

This function works, where startDate and endDate are JS Date objects. http://jsfiddle.net/n43Hr/

var getWeeklyEventCount = function (startDate, endDate) {
    var secondOccurrence = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()+7);
    if (endDate.getTime() >= secondOccurrence.getTime()) {
        return 1 + getWeeklyEventCount(secondOccurrence, endDate);
    }
    if (endDate.getTime() >= startDate.getTime()) {
        return 1;
    }
    return 0;
};
andi
  • 6,442
  • 1
  • 18
  • 43
0

There is plugin called jQuery Fullcalender

http://arshaw.com/fullcalendar/

which by default doesn't support this feature but you can go to below links which will help you to achieve the same

fullCalendar jQuery, repeat every monday?

https://coderwall.com/p/rti-rg

Community
  • 1
  • 1
Gautam
  • 3,276
  • 4
  • 31
  • 53