如何使用Google Calendar API更新日期和时间

时间:2012-11-20 09:49:26

标签: zend-framework frameworks google-calendar-api

我怎样才能更新日期和时间..一切都很好,除了日期和时间。每次更新后它们都是相同的,永远不会改变。您认为我的错误在哪里?

这是我用来更新事件的功能。

    function updateEvent ($client, $eventId, $newTitle, 
        $newDesc, $newWhere, $newStartDate, 
        $newStartTime, $newEndDate, $newEndTime, 
        $tzOffset)
            {   
                $gdataCal = new Zend_Gdata_Calendar($client);
                if ($eventOld = getEvent($client, $eventId)) {
                $eventOld->title = $gdataCal->newTitle($newTitle);
                $eventOld->where = array($gdataCal->newWhere($newWhere));
                $eventOld->content = $gdataCal->newContent("$newDesc");

                $when = $gdataCal->newWhen();

                if ($newStartTime!='' && $newEndTime!=''){
                  $when->startTime = "{$newStartDate}T{$newStartTime}:00.000{$tzOffset}:00";
                  $when->endTime = "{$newEndDate}T{$newEndTime}:00.000{$tzOffset}:00";
                }else {
                  $when->startTime = $newStartDate;
                  $when->endTime = $newEndDate;
                }

                try {
                  $eventOld->save();
                } catch (Zend_Gdata_App_Exception $e) {
                  var_dump($e);
                  return null;
                }
                  return 1;
              } else {
                return 0;
              }
            }

            if($_POST) {

              updateEvent($client, $id, $_POST['nameBg'], $_POST['descrBg'], $_POST['place'],
               $_POST['dateStart'],
               $_POST['dateEnd'],
               $_POST['timeStart'],
               $_POST['timeEnd'],
               '+02');



        $this->_helper->FlashMessenger->addMessage(array('success' => $this->_translate->_('Everything is OK.')));

        return $this->_helper->redirector->gotoRoute(array_merge($this->_urlCommon, array('action' => 'list')), 'lang-admin', true);


            } 

1 个答案:

答案 0 :(得分:0)

我发现我的问题在哪里..实际上,当我调用updateEvent()时,我已经更改了timeStart和dateEnd的位置..