本文整理汇总了PHP中TimeDate::swap_formats方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::swap_formats方法的具体用法?PHP TimeDate::swap_formats怎么用?PHP TimeDate::swap_formats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::swap_formats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCalendarLoadActivities
public function testCalendarLoadActivities()
{
$cal = new Calendar('month');
$cal->add_activities($GLOBALS['current_user']);
$format = $GLOBALS['current_user']->getUserDateTimePreferences();
$meeting = new Meeting();
$meeting->meeting_id = uniqid();
$meeting->date_start = $this->time_date->swap_formats("2012-01-01 11:00pm", 'Y-m-d h:ia', $format['date'] . ' ' . $format['time']);
$meeting->name = "test";
$cal->acts_arr = array();
$cal->acts_arr[$GLOBALS['current_user']->id] = array();
$cal->acts_arr[$GLOBALS['current_user']->id][] = new CalendarActivity($meeting);
$cal->load_activities();
$this->assertEquals($cal->items[0]['time_start'], $this->time_date->swap_formats("2012-01-01 11:00pm", 'Y-m-d h:ia', $format['time']), "Time should remain the same after load_activities");
}
示例2: sync_events
function sync_events($one_user = false, $sel_user = "")
{
global $beanList, $beanFiles, $path;
$use_offset_time = true;
$td = new TimeDate();
$arr_modules[] = "Meetings";
$arr_modules[] = "Calls";
$arr_modules[] = "Tasks";
global $timedate;
global $beanList, $beanFiles, $path, $current_user;
for ($tn = 0; $tn < count($arr_modules); $tn++) {
ob_start();
$module_name = $arr_modules[$tn];
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$seed = new $class_name();
$tbn = $seed->table_name;
$tablename = $tbn;
$cstmtbname2 = $tablename . "_cstm";
if ($one_user == true) {
if ($_SESSION['authenticated_user_id'] == "" and 1 == 2) {
} else {
if ($sel_user != "") {
$cu = $sel_user;
} else {
$cu = $_SESSION['authenticated_user_id'];
}
$tdus = new TimeDate();
$cus = new User();
$cus->retrieve($cu);
##############
global $current_user;
$current_user = $cus;
##############
$calendar_priv_add = $cus->google_mcalendar_c;
$crdatefilt = $cus->google_mafterdate_c;
$crdatefilt = $tdus->swap_formats($crdatefilt, $td->get_date_format(true, $cus), "Y-m-d");
unset($cus);
$sql_user = " 1 and {$tbn}.assigned_user_id='{$cu}' and ({$cstmtbname2}.old_id_c='' or {$cstmtbname2}.old_id_c is null ) ";
if ($crdatefilt != '') {
$sql_user .= " and {$tbn}.date_entered>='{$crdatefilt}' ";
}
$query = $sql_user;
}
}
$d1d = array();
$s = array();
$ch = array();
$fd = array();
$forexp = "";
$fort1d = "";
$t1d = "";
$nt = "";
$nt1 = "";
$cm = date("m");
$cy = date("Y");
unset($response);
global $max_events_upload_google;
$response = $seed->get_list($order_by, $query, $offset, 10000, $max_events_upload_google, false);
if ($tablename == "calls") {
}
$newdoc = $response['list'][$tn1];
if (1 == 1) {
$tablename = $tbn;
echo "<br>****** Get events from {$tablename}";
require_once 'modules/Calendar/DateTimeUtil.php';
$cm = date("m");
$cy = date("Y");
for ($tn1 = 0; $tn1 < count($response['list']); $tn1++) {
unset($a);
unset($a1);
unset($a2);
unset($s);
unset($current_user);
unset($user);
unset($td);
$a1 = $response['list'][$tn1];
$current_user = new User();
$current_user->retrieve($a1->assigned_user_id);
debugg("<br> current user for event " . $a1->assigned_user_id . " " . $current_user->name);
$user = $current_user;
$td = new TimeDate();
$user_google_mafterdate_c = $td->swap_formats($current_user->google_mafterdate_c, $td->get_date_format(true, $current_user), "Y-m-d");
$add_notifications = $current_user->google_mnotifications_c;
unset($a2);
if ($tablename == 'meetings') {
$a2 = new Meeting();
}
if ($tablename == 'calls') {
$a2 = new Call();
}
if ($tablename == 'tasks') {
$a2 = new Task();
}
unset($a);
$a = $a2->retrieve($a1->id);
if ($a->old_id_c == "" or 1 == 1) {
global $calls_prefix;
global $meetings_prefix;
global $tasks_prefix;
//.........这里部分代码省略.........
示例3: testConvertMmddyyyyFormatToYyyymmdd
public function testConvertMmddyyyyFormatToYyyymmdd()
{
$this->assertEquals('2007-11-02', $this->time_date->swap_formats('11-02-2007', 'm-d-Y', 'Y-m-d'));
}
示例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];
//.........这里部分代码省略.........
示例5: 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;
//.........这里部分代码省略.........