Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7932)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7953)
@@ -340,5 +340,4 @@
 	$repeat = Controller::read(array('concept' => 'repeat', 'id' => $id));
 
-	unset($repeat['schedulable']);
 	unset($repeat['id']);
 
@@ -347,8 +346,22 @@
 	if (isset($original['properties']['exceptions'])) {
 	    $exceptions = explode(',', $original['properties']['exceptions']);
-	    unset($repeat['exceptions']);
+	    $event = Controller::read(array('concept' => 'schedulable', 'id' => $repeat['schedulable']));
+
+        if(array_key_exists(0, $event)) $event = $event[0];
+
+        $date = new DateTime('now', new DateTimeZone('UTC'));
+
+        foreach($exceptions as &$e){
+            $date->setTimestamp((int) ($e / 1000));
+            $date->setTimezone( new DateTimeZone( $event['timezone'] ));
+            $e = ($date->getTimestamp() - $date->getOffset()).'000';
+        }
+
+        unset($repeat['exceptions']);
 	}
 
-	$lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1))));
+    unset($repeat['schedulable']);
+
+    $lastExceptions = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('AND', array('=', 'repeat', $id), array('=', 'exception', 1))));
 
 	//Recurepa as execeções anteriores caso exista
@@ -365,5 +378,5 @@
 	else if(!empty($exceptions))
 	    Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES ('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" );
-    }	    
+    }
 
     public function checkOccurrences($start, $end, $calendarIds) {
@@ -414,8 +427,22 @@
 
 	    foreach ($result as $id => $res){
-		
-                $ocurrences = array_unique($res);
+
+            $ocurrences = array_unique($res);
+
+            /*
+             * Check current range decoded
+             * */
+            $current = Controller::find(array('concept' => 'repeatOccurrence'), array("occurrence"), array('filter' => array('=', 'repeat', $id)));
+            $toDiff = array();
+
+            if(!empty($current))
+                foreach($current as $c) $toDiff[] = $c['occurrence'];
+
+            $ocurrences = array_diff($ocurrences, $toDiff);
+
+            if(!empty($ocurrences))
                 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,occurrence)VALUES('" . $id . "','" . implode("'),('" . $id . "', '", $ocurrences) . "')");
-            }
+
+        }
 	    $data = array();
 
@@ -436,5 +463,5 @@
 // 	$return = Controller::find( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( 'AND', array( '>=', 'occurrence', $origStart ), array( '<=', 'occurrence', $origEnd ), array( 'IN', 'repeat', $ids ) ), 'deepness' => $deep ) );
 
-	$return = Controller::service('PostgreSQL')->execResultSql('SELECT calendar_repeat_occurrence.occurrence as "occurrence", calendar_repeat.object_id as "schedulable" FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $origStart . '\' AND calendar_repeat_occurrence.occurrence <= \'' . $origEnd . '\' AND calendar_repeat_occurrence.repeat_id IN (\'' . implode('\',\'', $ids) . '\') AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND calendar_repeat_occurrence.exception != 1');
+	$return = Controller::service('PostgreSQL')->execResultSql('SELECT calendar_repeat_occurrence.occurrence as "occurrence", calendar_repeat.object_id as "schedulable" FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $origStart . '\' AND calendar_repeat_occurrence.occurrence <= \'' . $origEnd . '\' AND calendar_repeat_occurrence.repeat_id IN (\'' . implode('\',\'', $ids) . '\') AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND calendar_repeat_occurrence.exception != 1 order by calendar_repeat_occurrence.occurrence');
 
 	if (!is_array($return))
