diff --git a/blocks/SG_iCal_VEvent.php b/blocks/SG_iCal_VEvent.php index 00b1f10..166db35 100755 --- a/blocks/SG_iCal_VEvent.php +++ b/blocks/SG_iCal_VEvent.php @@ -179,6 +179,18 @@ class SG_iCal_VEvent { return $this->end - $this->start; } + /** + * Returns true if duration is multiple of 86400 + * @return bool + */ + public function isWholeDay() { + $dur = $this->getDuration(); + if ($dur > 0 && ($dur % 86400) == 0) { + return true; + } + return false; + } + /** * Returns the given property of the event. * @param string $prop diff --git a/demo/index.php b/demo/index.php index 4353f19..8551eb4 100644 --- a/demo/index.php +++ b/demo/index.php @@ -17,14 +17,14 @@ $evts = $query->Between($ical,strtotime('20100901'),strtotime('20101131')); $data = array(); foreach($evts as $id => $ev) { - $jsEvt = array( "id" => ($id+1), "title" => $ev->getProperty('summary'), "start" => $ev->getStart(), - "end" => $ev->getEnd(), - "allDay" => false + "end" => $ev->getEnd()-1, + "allDay" => $ev->isWholeDay() ); + $data[] = $jsEvt; if (isset($ev->recurrence)) { @@ -36,13 +36,15 @@ foreach($evts as $id => $ev) { $count++; $start = $next; $jsEvt["start"] = $start; - $jsEvt["end"] = $start + $ev->getDuration(); + $jsEvt["end"] = $start + $ev->getDuration()-1; + $data[] = $jsEvt; } } } - +//echo(date('Ymd\n',$data[0][start])); +//echo(date('Ymd\n',$data[1][start])); //dump_t($data); $events = "events:".json_encode($data).',';