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


PHP TimeDate::handle_offset方法代码示例

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


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

示例1: testUserDateFormat

 public function testUserDateFormat()
 {
     $gmt_default_date_start = $this->time_date->get_gmt_db_datetime();
     $date1 = $this->time_date->handle_offset($gmt_default_date_start, $GLOBALS['timedate']->get_date_time_format());
     $date2 = $this->time_date->asUser($this->time_date->getNow());
     $this->assertEquals($date1, $date2, "HandleOffset should be equaivalent to nowDb");
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:7,代码来源:CalendarTest.php

示例2: createSugarIcal


//.........这里部分代码省略.........
             $ical_array[] = array("SUMMARY", $event->name);
             $ical_array[] = array("DTSTART;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $timedate->tzUser($act->start_time, $current_user)->format(self::UTC_FORMAT)));
             $ical_array[] = array("DTEND;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $timedate->tzUser($act->end_time, $current_user)->format(self::UTC_FORMAT)));
             $ical_array[] = array("DTSTAMP", $dtstamp);
             $ical_array[] = array("DESCRIPTION", $event->description);
             $ical_array[] = array("URL;VALUE=URI", $sugar_config['site_url'] . "/index.php?module=" . $event->module_dir . "&action=DetailView&record=" . $event->id);
             $ical_array[] = array("UID", $event->id);
             if ($event->object_name == "Meeting") {
                 $ical_array[] = array("LOCATION", $event->location);
                 $eventUsers = $event->get_meeting_users();
                 $query = "SELECT contact_id as id from meetings_contacts where meeting_id='{$event->id}' AND deleted=0";
                 $eventContacts = $event->build_related_list($query, new Contact());
                 $eventAttendees = array_merge($eventUsers, $eventContacts);
                 if (is_array($eventAttendees)) {
                     foreach ($eventAttendees as $attendee) {
                         if ($attendee->id != $user_bean->id) {
                             // Define the participant status
                             $participant_status = '';
                             if (!empty($attendee->accept_status)) {
                                 switch ($attendee->accept_status) {
                                     case 'accept':
                                         $participant_status = ';PARTSTAT=ACCEPTED';
                                         break;
                                     case 'decline':
                                         $participant_status = ';PARTSTAT=DECLINED';
                                         break;
                                     case 'tentative':
                                         $participant_status = ';PARTSTAT=TENTATIVE';
                                         break;
                                 }
                             }
                             $ical_array[] = array('ATTENDEE' . $participant_status . ';CN="' . $attendee->get_summary_text() . '"', 'mailto:' . (!empty($attendee->email1) ? $attendee->email1 : 'none@none.tld'));
                         }
                     }
                 }
             }
             if ($event->object_name == "Call") {
                 $eventUsers = $event->get_call_users();
                 $eventContacts = $event->get_contacts();
                 $eventAttendees = array_merge($eventUsers, $eventContacts);
                 if (is_array($eventAttendees)) {
                     foreach ($eventAttendees as $attendee) {
                         if ($attendee->id != $user_bean->id) {
                             // Define the participant status
                             $participant_status = '';
                             if (!empty($attendee->accept_status)) {
                                 switch ($attendee->accept_status) {
                                     case 'accept':
                                         $participant_status = ';PARTSTAT=ACCEPTED';
                                         break;
                                     case 'decline':
                                         $participant_status = ';PARTSTAT=DECLINED';
                                         break;
                                     case 'tentative':
                                         $participant_status = ';PARTSTAT=TENTATIVE';
                                         break;
                                 }
                             }
                             $ical_array[] = array('ATTENDEE' . $participant_status . ';CN="' . $attendee->get_summary_text() . '"', 'mailto:' . (!empty($attendee->email1) ? $attendee->email1 : 'none@none.tld'));
                         }
                     }
                 }
             }
             if (isset($event->reminder_time) && $event->reminder_time > 0 && $event->status != "Held") {
                 $ical_array[] = array("BEGIN", "VALARM");
                 $ical_array[] = array("TRIGGER", "-PT");
                 $ical_array[] = array("ACTION", "DISPLAY");
                 $ical_array[] = array("DESCRIPTION", $event->name);
                 $ical_array[] = array("END", "VALARM");
             }
             $ical_array[] = array("END", "VEVENT");
         }
     }
     $str = vCal::create_ical_string_from_array($ical_array, true);
     require_once 'include/TimeDate.php';
     $timedate = new TimeDate();
     $today = gmdate("Y-m-d");
     $today = $timedate->handle_offset($today, $timedate->dbDayFormat, false);
     require_once 'modules/ProjectTask/ProjectTask.php';
     $where = "project_task.assigned_user_id='{$user_bean->id}' " . "AND (project_task.status IS NULL OR (project_task.status!='Deferred')) " . "AND (project_task.date_start IS NULL OR " . CalendarActivity::get_occurs_within_where_clause('project_task', '', $start_date_time, $end_date_time, 'date_start', 'month') . ")";
     $seedProjectTask = new ProjectTask();
     $projectTaskList = $seedProjectTask->get_full_list("", $where);
     if (is_array($projectTaskList)) {
         foreach ($projectTaskList as $projectTask) {
             $str .= $this->createSugarIcalTodo($user_bean, $projectTask, "ProjectTask", $dtstamp);
         }
     }
     if ($taskAsVTODO) {
         require_once 'modules/Tasks/Task.php';
         $where = "tasks.assigned_user_id='{$user_bean->id}' " . "AND (tasks.status IS NULL OR (tasks.status!='Deferred')) " . "AND (tasks.date_start IS NULL OR " . CalendarActivity::get_occurs_within_where_clause('tasks', '', $start_date_time, $end_date_time, 'date_start', 'month') . ")";
         $seedTask = new Task();
         $taskList = $seedTask->get_full_list("", $where);
         if (is_array($taskList)) {
             foreach ($taskList as $task) {
                 $str .= $this->createSugarIcalTodo($user_bean, $task, "Tasks", $dtstamp);
             }
         }
     }
     return $str;
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:101,代码来源:iCal.php

示例3: GoogleCalls

 function GoogleCalls(&$bean, $event, $arguments)
 {
     $okev = true;
     $_SESSION["mass_upd_assigned"] = false;
     if (isset($_REQUEST["massupdate"])) {
         if ($_REQUEST["massupdate"] == true) {
             $okev = false;
             if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") {
                 $okev = true;
             }
             if ($_REQUEST['assigned_user_id'] != "") {
                 $_SESSION["mass_upd_assigned"] = true;
             }
         }
     }
     if ($okev == true) {
         if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") {
             ### skip if called from sync.php logic hook
             global $timedate;
             $offset_val = ".000+02:00";
             $td = new TimeDate();
             $tablename = $bean->table_name;
             $a = $response['list'][$tn1];
             $s = array();
             #  echo "<br>**********Event ******* id=$a[id] ***** name=$a[name]";
             $s["title"] = $bean->name;
             if ($tablename == 'meetings') {
                 $s["title"] = "Meeting: " . $s["title"];
             }
             if ($tablename == 'calls') {
                 $s["title"] = "Call: " . $s["title"];
             }
             if ($tablename == 'tasks') {
                 $s["title"] = "Task: " . $s["title"];
             }
             $s["content"] = $bean->description;
             $s["where"] = $bean->location;
             $s["startDay"] = $bean->date_start;
             $s["startTime"] = $bean->time_start;
             $s["endDay"] = $bean->date_end;
             $s["reminder_time"] = $bean->reminder_time / 60;
             if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) {
                 $s["reminder_time"] = 10;
             }
             if ($bean->date_start == '' and $bean->date_due != "") {
                 $s["startDay"] = $bean->date_due;
                 #### for tasks if no start date
             } else {
                 $s["startDay"] = $bean->date_start;
             }
             #   print_r($s);
             global $current_user;
             $pd = $s["startDay"];
             ####260608
             #$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user);
             $date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
             $date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
             $date_start_array = split(" ", trim($date_start_in_db_fmt));
             $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]);
             $tt1 = $td->to_display_date_time($bean->date_start, true, true, false);
             $user = $current_user;
             $s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user);
             $date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user);
             ###### problem with offset ... if record is at 23.15 gmt +2 .. date problem
             $ch = explode(" ", $s["startDay"]);
             if ($ch['1'] == "00:00" or $ch['1'] == "00.00") {
                 #### 120608 bogdan if task and 12:00 goes to next day $s["startDay"]  = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user);
                 $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
                 $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
             } else {
                 $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
                 $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
             }
             $plugin_format = "d/m/Y H:i";
             if ($td->get_date_time_format(true, $current_user) != $plugin_format) {
                 ##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user),  $plugin_format);
                 $plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format);
             } else {
                 ##260608  $plugin_date_start=$pd;
                 $plugin_date_due = $bean->date_due;
             }
             $plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format);
             $plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format);
             #################################################
             $d1 = explode("/", $plugin_date_start);
             global $current_user;
             $d1[2] = explode(" ", $d1[2]);
             $d1[2] = $d1[2][0];
             if ($bean->time_start != '' and 1 == 2) {
                 $t1 = explode(":", $bean->time_start);
             } else {
                 $fort1 = explode(" ", $plugin_date_start);
                 $fort1 = $fort1[1];
                 $t1 = explode(":", $fort1);
             }
             $t1[1] = round($t1[1]);
             $untill = mktime($t1[0] + $bean->duration_hours, $t1[1] + $bean->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]);
             if ($tablename == 'tasks') {
                 if ($plugin_date_due == "" or $bean->date_due == "") {
                     $forexp = $plugin_date_start;
//.........这里部分代码省略.........
开发者ID:Terradex,项目名称:sugar,代码行数:101,代码来源:google_calendar_plg.php

示例4: GoogleCalls

 function GoogleCalls(&$bean, $event, $arguments)
 {
     echo "<br>aa " . $bean->id;
     echo "<br>aa " . $bean->name;
     echo "<br>sess delete " . $_SESSION["mass_upd_assigned"];
     echo "<br>sess delete" . $_REQUEST["massupdate"];
     echo "<br>";
     $okev = true;
     $_SESSION["mass_upd_assigned"] = false;
     if (isset($_REQUEST["massupdate"])) {
         if ($_REQUEST["massupdate"] == true) {
             $okev = false;
             if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") {
                 $okev = true;
             }
             if ($_REQUEST['assigned_user_id'] != "") {
                 $_SESSION["mass_upd_assigned"] = true;
             }
         }
     }
     if ($okev == true) {
         if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") {
             ### skip if called from sync.php logic hook
             echo "<br>delete from sugar logic hook ";
             global $timedate;
             $offset_val = ".000+02:00";
             $td = new TimeDate();
             echo "<br>old bean id " . $bean->id;
             echo "<br>old bean name " . $bean->name;
             echo "<br>tablename ";
             $tablename = $bean->table_name;
             $a = $response['list'][$tn1];
             $s = array();
             $s["title"] = $bean->name;
             if ($tablename == 'meetings') {
                 $s["title"] = "Meeting: " . $s["title"];
             }
             if ($tablename == 'calls') {
                 $s["title"] = "Call: " . $s["title"];
             }
             if ($tablename == 'tasks') {
                 $s["title"] = "Task: " . $s["title"];
             }
             echo "<br>bean date start " . $bean->date_start;
             $s["content"] = $bean->description;
             $s["where"] = $bean->location;
             $s["startDay"] = $bean->date_start;
             $s["startTime"] = $bean->time_start;
             $s["endDay"] = $bean->date_end;
             $s["reminder_time"] = $bean->reminder_time / 60;
             if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) {
                 $s["reminder_time"] = 10;
             }
             if ($bean->date_start == '' and $bean->date_due != "") {
                 $s["startDay"] = $bean->date_due;
                 #### for tasks if no start date
             } else {
                 $s["startDay"] = $bean->date_start;
             }
             #   print_r($s);
             global $current_user;
             $pd = $s["startDay"];
             ####260608
             #$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user);
             $date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
             $date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
             $date_start_array = split(" ", trim($date_start_in_db_fmt));
             $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]);
             $tt1 = $td->to_display_date_time($bean->date_start, true, true, false);
             $user = $current_user;
             $s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user);
             $date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user);
             echo "<br>bean date start1 " . $s["startTime"];
             ##260806 $s["startTime"]=$date_start_array[1];
             echo "<br>bean date start2 " . $s["startTime"];
             $ch = explode(" ", $s["startDay"]);
             if ($ch['1'] == "00:00" or $ch['1'] == "00.00") {
                 #### 120608 bogdan if task and 12:00 goes to next day $s["startDay"]  = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user);
                 $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
                 $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
             } else {
                 $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
                 $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
             }
             $plugin_format = "d/m/Y H:i";
             if ($td->get_date_time_format(true, $current_user) != $plugin_format) {
                 ##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user),  $plugin_format);
                 $plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format);
             } else {
                 ##260608  $plugin_date_start=$pd;
                 $plugin_date_due = $bean->date_due;
             }
             $plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format);
             $plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format);
             echo "<br>plg date start " . $plugin_date_start;
             #################################################
             $d1 = explode("/", $plugin_date_start);
             global $current_user;
             $d1[2] = explode(" ", $d1[2]);
             $d1[2] = $d1[2][0];
//.........这里部分代码省略.........
开发者ID:Terradex,项目名称:sugar,代码行数:101,代码来源:before_delete_google.php

示例5: createSugarIcal

 /**
  * Creates the string for the user's events and todos between the given start
  * and end times
  *
  * @param UserBean $user_bean the current UserBean
  * @param DateTime $start_date_time the start date to search from
  * @param DateTime $end_date_time the end date to search to
  * @param string $dtstamp the current timestamp
  * @return string the entries for events and todos
  */
 protected function createSugarIcal(&$user_bean, &$start_date_time, &$end_date_time, $dtstamp)
 {
     $str = '';
     global $DO_USER_TIME_OFFSET, $sugar_config, $current_user, $timedate;
     $acts_arr = CalendarActivity::get_activities($user_bean->id, false, $start_date_time, $end_date_time, 'month');
     $hide_calls = false;
     if (!empty($_REQUEST['hide_calls']) && $_REQUEST['hide_calls'] == "true") {
         $hide_calls = true;
     }
     // loop thru each activity, get start/end time in UTC, and return iCal strings
     foreach ($acts_arr as $act) {
         $event = $act->sugar_bean;
         if (!$hide_calls || $hide_calls && $event->object_name != "Call") {
             $str .= "BEGIN:VEVENT\n";
             $str .= "SUMMARY:" . $event->name . "\n";
             $str .= "DTSTART;TZID=" . $user_bean->getPreference('timezone') . ":" . str_replace("Z", "", $timedate->tzUser($act->start_time, $current_user)->format(self::UTC_FORMAT)) . "\n";
             $str .= "DTEND;TZID=" . $user_bean->getPreference('timezone') . ":" . str_replace("Z", "", $timedate->tzUser($act->end_time, $current_user)->format(self::UTC_FORMAT)) . "\n";
             $str .= "DTSTAMP:" . $dtstamp . "\n";
             $str .= "DESCRIPTION:" . $this->escapeNls($event->description) . "\n";
             $str .= "URL;VALUE=URI:" . $sugar_config['site_url'] . "/index.php?module=" . $event->module_dir . "&action=DetailView&record=" . $event->id . "\n";
             $str .= "UID:" . $event->id . "\n";
             if ($event->object_name == "Meeting") {
                 $str .= "LOCATION:" . $event->location . "\n";
                 $eventUsers = $event->get_meeting_users();
                 $query = "SELECT contact_id as id from meetings_contacts where meeting_id='{$event->id}' AND deleted=0";
                 $eventContacts = $event->build_related_list($query, new Contact());
                 $eventAttendees = array_merge($eventUsers, $eventContacts);
                 if (is_array($eventAttendees)) {
                     foreach ($eventAttendees as $attendee) {
                         if ($attendee->id != $user_bean->id) {
                             $str .= 'ATTENDEE;CN="' . $attendee->get_summary_text() . '":mailto:' . $attendee->email1 . "\n";
                         }
                     }
                 }
             }
             if ($event->object_name == "Call") {
                 $eventUsers = $event->get_call_users();
                 $eventContacts = $event->get_contacts();
                 $eventAttendees = array_merge($eventUsers, $eventContacts);
                 if (is_array($eventAttendees)) {
                     foreach ($eventAttendees as $attendee) {
                         if ($attendee->id != $user_bean->id) {
                             $str .= 'ATTENDEE;CN="' . $attendee->get_summary_text() . '":mailto:' . $attendee->email1 . "\n";
                         }
                     }
                 }
             }
             if ($event->reminder_time > 0 && $event->status != "Held") {
                 $str .= "BEGIN:VALARM\n";
                 $str .= "TRIGGER:-PT" . $event->reminder_time / 60 . "M\n";
                 $str .= "ACTION:DISPLAY\n";
                 $str .= "DESCRIPTION:" . $event->name . "\n";
                 $str .= "END:VALARM\n";
             }
             $str .= "END:VEVENT\n";
         }
     }
     require_once 'include/TimeDate.php';
     $timedate = new TimeDate();
     $today = gmdate("Y-m-d");
     $today = $timedate->handle_offset($today, $timedate->dbDayFormat, false);
     require_once 'modules/ProjectTask/ProjectTask.php';
     $where = "project_task.assigned_user_id='{$user_bean->id}' " . "AND (project_task.status IS NULL OR (project_task.status!='Deferred')) " . "AND (project_task.date_start IS NULL OR project_task.date_start <= '{$today}')";
     $seedProjectTask = new ProjectTask();
     $projectTaskList = $seedProjectTask->get_full_list("", $where);
     if (is_array($projectTaskList)) {
         foreach ($projectTaskList as $projectTask) {
             $str .= $this->createSugarIcalTodo($user_bean, $projectTask, "ProjectTask", $dtstamp);
         }
     }
     require_once 'modules/Tasks/Task.php';
     $where = "tasks.assigned_user_id='{$user_bean->id}' " . "AND (tasks.status IS NULL OR (tasks.status!='Deferred')) " . "AND (tasks.date_start IS NULL OR tasks.date_start <= '{$today}')";
     $seedTask = new Task();
     $taskList = $seedTask->get_full_list("", $where);
     if (is_array($taskList)) {
         foreach ($taskList as $task) {
             $str .= $this->createSugarIcalTodo($user_bean, $task, "Tasks", $dtstamp);
         }
     }
     return $str;
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:91,代码来源:iCal.php


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