diff --git a/calendar/export_execute.php b/calendar/export_execute.php
index 9f2700e..008878c 100644
--- a/calendar/export_execute.php
+++ b/calendar/export_execute.php
@@ -189,14 +189,19 @@ foreach($events as $event) {
     $ev->add_property('class', 'PUBLIC'); // PUBLIC / PRIVATE / CONFIDENTIAL
     $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified));
     $ev->add_property('dtstamp', Bennu::timestamp_to_datetime()); // now
-    $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts
     if ($event->timeduration > 0) {
         //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
+        $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts
         $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
     }
+    else {
+         // when no duration is present, ie an all day event, VALUE should be date instead of time and dtend = dtstart + 1 day
+        $ev->add_property('dtstart', Bennu::timestamp_to_date($event->timestart),array('value' => 'DATE')); // all day event
+        $ev->add_property('dtend', Bennu::timestamp_to_date($event->timestart+86400),array('value' => 'DATE')); // all day event
+    }
     if ($event->courseid != 0) {
         $coursecontext = context_course::instance($event->courseid);
-        $ev->add_property('categories', format_string($courses[$event->courseid]->shortname, true, array('context' => $coursecontext)));
+	$ev->add_property('categories', format_string($courses[$event->courseid]->shortname, true, array('context' => $coursecontext))); 
     }
     $ical->add_component($ev);
 }
diff --git a/lib/bennu/bennu.class.php b/lib/bennu/bennu.class.php
index b278c14..4e6f09b 100644
--- a/lib/bennu/bennu.class.php
+++ b/lib/bennu/bennu.class.php
@@ -20,6 +20,14 @@ class Bennu {
         return gmstrftime('%Y%m%dT%H%M%SZ', $t);
     }
 
+    static function timestamp_to_date($t = NULL) {
+        if($t === NULL) {
+            $t = time();
+        }
+        return strftime('%Y%m%d', $t);
+    }
+
+
     static function generate_guid() {
         // Implemented as per the Network Working Group draft on UUIDs and GUIDs
     
