'Get calendar events for given user'

def get_calendar_events(self):

    from frappe.desk.doctype.event.event import get_events
    events = (get_events(self.future_from_date.strftime(u'%Y-%m-%d'), self.future_to_date.strftime(u'%Y-%m-%d')) or [])
    event_count = 0
    for (i, e) in enumerate(events):
        e.starts_on_label = format_time(e.starts_on)
        e.ends_on_label = (format_time(e.ends_on) if e.ends_on else None)
        e.date = formatdate(e.starts)
        e.link = get_url_to_form(u'Event', e.name)
        event_count += 1
    return (events, event_count)
