当前位置: 首页>>代码示例>>PHP>>正文


PHP SugarDateTime::setDate方法代码示例

本文整理汇总了PHP中SugarDateTime::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarDateTime::setDate方法的具体用法?PHP SugarDateTime::setDate怎么用?PHP SugarDateTime::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SugarDateTime的用法示例。


在下文中一共展示了SugarDateTime::setDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAgenda

 public function getAgenda($api, $args)
 {
     // Fetch the next 14 days worth of meetings (limited to 20)
     $end_time = new SugarDateTime("+14 days");
     $start_time = new SugarDateTime("-1 hour");
     $meeting = BeanFactory::newBean('Meetings');
     $meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
     // Setup the breaks for the various time periods
     $datetime = new SugarDateTime();
     $today_stamp = $datetime->get_day_end()->getTimestamp();
     $tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
     $timeDate = TimeDate::getInstance();
     $returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
     foreach ($meetingList['list'] as $meetingBean) {
         $meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
         $meetingData = $this->formatBean($api, $args, $meetingBean);
         if ($meetingStamp < $today_stamp) {
             $returnedMeetings['today'][] = $meetingData;
         } else {
             if ($meetingStamp < $tomorrow_stamp) {
                 $returnedMeetings['tomorrow'][] = $meetingData;
             } else {
                 $returnedMeetings['upcoming'][] = $meetingData;
             }
         }
     }
     return $returnedMeetings;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:28,代码来源:MeetingsApi.php

示例2: createSugarIcalTodo

 /**
  * Create a todo entry for the given task.
  *
  * @param UserBean $user_bean the current UserBean
  * @param Task $task the task for the todo entry
  * @param string $moduleName the name of the task module
  * @param string $dtstamp the current timestamp
  * @return string the todo entry for the task
  */
 protected function createSugarIcalTodo($user_bean, $task, $moduleName, $dtstamp)
 {
     global $sugar_config;
     $ical_array = array();
     $ical_array[] = array("BEGIN", "VTODO");
     $validDueDate = isset($task->date_due) && $task->date_due != "" && $task->date_due != "0000-00-00";
     $validDueTime = isset($task->time_due) && $task->time_due != "";
     $dueYear = 1970;
     $dueMonth = 1;
     $dueDay = 1;
     $dueHour = 0;
     $dueMin = 0;
     if ($validDueDate) {
         $dateDueArr = explode("-", $task->date_due);
         $dueYear = (int) $dateDueArr[0];
         $dueMonth = (int) $dateDueArr[1];
         $dueDay = (int) $dateDueArr[2];
         if ($validDueTime) {
             $timeDueArr = explode(":", $task->time_due);
             $dueHour = (int) $timeDueArr[0];
             $dueMin = (int) $timeDueArr[1];
         }
     }
     $date_arr = array('day' => $dueDay, 'month' => $dueMonth, 'hour' => $dueHour, 'min' => $dueMin, 'year' => $dueYear);
     $due_date_time = new SugarDateTime();
     $due_date_time->setDate($dueYear, $dueMonth, $dueDay);
     $due_date_time->setTime($dueHour, $dueMin);
     $ical_array[] = array("DTSTART;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $this->getUtcDateTime($due_date_time)));
     $ical_array[] = array("DTSTAMP", $dtstamp);
     $ical_array[] = array("SUMMARY", $task->name);
     $ical_array[] = array("UID", $task->id);
     if ($validDueDate) {
         $iCalDueDate = str_replace("-", "", $task->date_due);
         if (strlen($iCalDueDate) > 8) {
             $iCalDueDate = substr($iCalDueDate, 0, 8);
         }
         $ical_array[] = array("DUE;VALUE=DATE", $iCalDueDate);
     }
     if ($moduleName == "ProjectTask") {
         $ical_array[] = array("DESCRIPTION:Project", $task->project_name . vCal::EOL . vCal::EOL . $task->description);
     } else {
         $ical_array[] = array("DESCRIPTION", $task->description);
     }
     $ical_array[] = array("URL;VALUE=URI", $sugar_config['site_url'] . "/index.php?module=" . $moduleName . "&action=DetailView&record=" . $task->id);
     if ($task->status == 'Completed') {
         $ical_array[] = array("STATUS", "COMPLETED");
         $ical_array[] = array("PERCENT-COMPLETE", "100");
         $ical_array[] = array("COMPLETED", $this->getUtcDateTime($due_date_time));
     } else {
         if (!empty($task->percent_complete)) {
             $ical_array[] = array("PERCENT-COMPLETE", $task->percent_complete);
         }
     }
     if ($task->priority == "Low") {
         $ical_array[] = array("PRIORITY", "9");
     } else {
         if ($task->priority == "Medium") {
             $ical_array[] = array("PRIORITY", "5");
         } else {
             if ($task->priority == "High") {
                 $ical_array[] = array("PRIORITY", "1");
             }
         }
     }
     $ical_array[] = array("END", "VTODO");
     return vCal::create_ical_string_from_array($ical_array, true);
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:76,代码来源:iCal.php

示例3: createSugarIcalTodo

 /**
  * Create a todo entry for the given task.
  *
  * @param UserBean $user_bean the current UserBean
  * @param Task $task the task for the todo entry
  * @param string $moduleName the name of the task module
  * @param string $dtstamp the current timestamp
  * @return string the todo entry for the task
  */
 protected function createSugarIcalTodo($user_bean, $task, $moduleName, $dtstamp)
 {
     global $sugar_config;
     $str = "";
     $str .= "BEGIN:VTODO\n";
     $validDueDate = isset($task->date_due) && $task->date_due != "" && $task->date_due != "0000-00-00";
     $validDueTime = isset($task->time_due) && $task->time_due != "";
     $dueYear = 1970;
     $dueMonth = 1;
     $dueDay = 1;
     $dueHour = 0;
     $dueMin = 0;
     if ($validDueDate) {
         $dateDueArr = split("-", $task->date_due);
         $dueYear = (int) $dateDueArr[0];
         $dueMonth = (int) $dateDueArr[1];
         $dueDay = (int) $dateDueArr[2];
         if ($validDueTime) {
             $timeDueArr = split(":", $task->time_due);
             $dueHour = (int) $timeDueArr[0];
             $dueMin = (int) $timeDueArr[1];
         }
     }
     $date_arr = array('day' => $dueDay, 'month' => $dueMonth, 'hour' => $dueHour, 'min' => $dueMin, 'year' => $dueYear);
     $due_date_time = new SugarDateTime();
     $due_date_time->setDate($dueYear, $dueMonth, $dueDay);
     $due_date_time->setTime($dueHour, $dueMin);
     $str .= "DTSTART;TZID=" . $user_bean->getPreference('timezone') . ":" . str_replace("Z", "", $this->getUtcDateTime($due_date_time)) . "\n";
     $str .= "DTSTAMP:" . $dtstamp . "\n";
     $str .= "SUMMARY:" . $task->name . "\n";
     $str .= "UID:" . $task->id . "\n";
     if ($validDueDate) {
         $iCalDueDate = str_replace("-", "", $task->date_due);
         if (strlen($iCalDueDate) > 8) {
             $iCalDueDate = substr($iCalDueDate, 0, 8);
         }
         $str .= "DUE;VALUE=DATE:" . $iCalDueDate . "\n";
     }
     if ($moduleName == "ProjectTask") {
         $str .= "DESCRIPTION:Project: " . $task->project_name . "\\n\\n" . $this->escapeNls($task->description) . "\n";
     } else {
         $str .= "DESCRIPTION:" . $this->escapeNls($task->description) . "\n";
     }
     $str .= "URL;VALUE=URI:" . $sugar_config['site_url'] . "/index.php?module=" . $moduleName . "&action=DetailView&record=" . $task->id . "\n";
     if ($task->status == 'Completed') {
         $str .= "STATUS:COMPLETED\n";
         $str .= "PERCENT-COMPLETE:100\n";
         $str .= "COMPLETED:" . $this->getUtcDateTime($due_date_time) . "\n";
     } else {
         if (!empty($task->percent_complete)) {
             $str .= "PERCENT-COMPLETE:" . $task->percent_complete . "\n";
         }
     }
     if ($task->priority == "Low") {
         $str .= "PRIORITY:9\n";
     } else {
         if ($task->priority == "Medium") {
             $str .= "PRIORITY:5\n";
         } else {
             if ($task->priority == "High") {
                 $str .= "PRIORITY:1\n";
             }
         }
     }
     $str .= "END:VTODO\n";
     return $str;
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:76,代码来源:iCal.php

示例4: getGenericStartEndByDuration

 /**
  * @param integer $duration
  * @param string|null $start_date The starting date in format of Y-m-d
  * @return array
  */
 public function getGenericStartEndByDuration($duration, $start_date = null)
 {
     $mapping = array('current' => 0, 'next' => 3, 'year' => 12);
     if (array_key_exists($duration, $mapping)) {
         $duration = $mapping[$duration];
     } elseif (!is_numeric($duration)) {
         $duration = 0;
     }
     $start = false;
     if (!is_null($start_date)) {
         $start = SugarDateTime::createFromFormat('Y-m-d', $start_date);
         $end = SugarDateTime::createFromFormat('Y-m-d', $start_date);
     }
     if ($start === false) {
         $start = new SugarDateTime();
         $end = new SugarDateTime();
     }
     // since we subtract one from the month, we need to add one to the duration since php is
     // not zero 0 based for months
     // figure out what the starting month is.
     $startMonth = floor(($start->month - 1) / 3) * 3 + $duration + 1;
     $year = $start->year;
     $endYear = $year;
     $endMonth = $startMonth + 3;
     // if the end month is dec, we put it to Jan and increase the end year as well so it goes back to the last
     // day of dec
     if ($endMonth == 12) {
         $endYear++;
         $endMonth = 1;
     }
     if ($duration == 12) {
         $endYear++;
         $startMonth = 1;
         $endMonth = 1;
     }
     $start->setDate($year, $startMonth, 1);
     $end->setDate($endYear, $endMonth, 0);
     // since we are using timestamp, we need to convert this into UTC since that is
     // what the DB is storing as
     $tz = new DateTimeZone("UTC");
     return array('start_date' => $start->asDbDate(false), 'start_date_timestamp' => $start->setTimezone($tz)->setTime(0, 0, 0)->format('U'), 'end_date' => $end->asDbDate(false), 'end_date_timestamp' => $end->setTimezone($tz)->setTime(0, 0, 0)->format('U'));
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:47,代码来源:TimePeriod.php


注:本文中的SugarDateTime::setDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。