calendaring/event.cpp calendaring/event.h

Christian Mollekopf mollekopf at kolabsys.com
Fri Oct 26 18:34:24 CEST 2012


 calendaring/event.cpp |   11 +++++++++++
 calendaring/event.h   |    5 +++++
 2 files changed, 16 insertions(+)

New commits:
commit 1780428ab110e368a92bb96aa055f7a21521b7c6
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Fri Oct 26 17:39:34 2012 +0200

    Added function to find the last occurrence of a recurring event.

diff --git a/calendaring/event.cpp b/calendaring/event.cpp
index 7571cd4..29f7017 100644
--- a/calendaring/event.cpp
+++ b/calendaring/event.cpp
@@ -224,5 +224,16 @@ cDateTime Calendaring::Event::getOccurenceEndDate(const cDateTime &startDate)
     return Kolab::Conversion::fromDate(event->endDateForStart(start));
 }
 
+cDateTime Calendaring::Event::getLastOccurrence() const
+{
+    KCalCore::Event::Ptr event = Kolab::Conversion::toKCalCore(*this);
+    if (!event->recurs()) {
+        return cDateTime();
+    }
+    const KDateTime endDate = event->recurrence()->endDateTime();
+    return Kolab::Conversion::fromDate(endDate);
+}
+
+
     };
 };
diff --git a/calendaring/event.h b/calendaring/event.h
index e5e2a7a..e9b5ce4 100644
--- a/calendaring/event.h
+++ b/calendaring/event.h
@@ -106,6 +106,11 @@ public:
      */
     Kolab::cDateTime getOccurenceEndDate(const Kolab::cDateTime &start);
 
+    /**
+     * Returns the last occurrence, or and invalid cDateTime if the event is not recurring or recurring idenfinitely.
+     */
+    Kolab::cDateTime getLastOccurrence() const;
+
 private:
     Kolab::Attendee *getAttendee(const ContactReference &);
     Kolab::ITipHandler mITipHandler;





More information about the commits mailing list