Appgutta / AGCalendar

Calendar module for Titanium
Other
80 stars 25 forks source link

Recurring events #2

Closed ChrisRM closed 12 years ago

ChrisRM commented 12 years ago

Dan Giulvezan - See comment

Nice job, works great! Any plans to support recurring events?

ChrisRM commented 12 years ago

Fixed. This addition will only work when using EventKit as your datasource.

// As recurring events only works when using eventkit 
// as our datasource, make sure its set.
Ti.Calendar.dataSource("eventkit");

// For this event, we want it to repeat every other day in one month.
// Start by creating the end date for our recurrence rule.
var recurringEnd = new Date();
recurringEnd.setMonth(recurringEnd.getMonth()+1);

// Let's make the event last for 3 hours.
var eventEnd = new Date();
eventEnd.setHours(eventEnd.getHours()+3);

// Create and add the event to the calendar.
Ti.Calendar.addEvent({
    title: "Once every other day in one month",
    startDate: new Date(),
    endDate: eventEnd,
    location: "Appcelerator's HQ",
    note: "A note...",
    recurrence: { 
        frequency: "day", // day, week, month, year
        interval: 2, // 1 = every day, 2 = every other day, 3 = every third day and so on...
        end: recurringEnd 
    }
});