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


PHP CDate::addSpan方法代码示例

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


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

示例1: getRecurrentEventforPeriod

 /**
 * Calculating if an recurrent date is in the given period
 * @param Date Start date of the period
 * @param Date End date of the period
 * @param Date Start date of the Date Object
 * @param Date End date of the Date Object
 * @param integer Type of Recurrence
 * @param integer Times of Recurrence
 * @param integer Time of Recurrence
 * @return array Calculated Start and End Dates for the recurrent Event for the given Period
 */
 function getRecurrentEventforPeriod($start_date, $end_date, $event_start_date, $event_end_date, $event_recurs, $event_times_recuring, $j)
 {
     //this array will be returned
     $transferredEvent = array();
     //create Date Objects for Event Start and Event End
     $eventStart = new CDate($event_start_date);
     $eventEnd = new CDate($event_end_date);
     //Time of Recurence = 0 (first occurence of event) has to be checked, too.
     if ($j > 0) {
         switch ($event_recurs) {
             case 1:
                 $eventStart->addSpan(new Date_Span(3600 * $j));
                 $eventEnd->addSpan(new Date_Span(3600 * $j));
                 break;
             case 2:
                 $eventStart->addDays($j);
                 $eventEnd->addDays($j);
                 break;
             case 3:
                 $eventStart->addDays(7 * $j);
                 $eventEnd->addDays(7 * $j);
                 break;
             case 4:
                 $eventStart->addDays(14 * $j);
                 $eventEnd->addDays(14 * $j);
                 break;
             case 5:
                 $eventStart->addMonths($j);
                 $eventEnd->addMonths($j);
                 break;
             case 6:
                 $eventStart->addMonths(3 * $j);
                 $eventEnd->addMonths(3 * $j);
                 break;
             case 7:
                 $eventStart->addMonths(6 * $j);
                 $eventEnd->addMonths(6 * $j);
                 break;
             case 8:
                 $eventStart->addMonths(12 * $j);
                 $eventEnd->addMonths(12 * $j);
                 break;
             default:
                 break;
         }
     }
     if ($start_date->compare($start_date, $eventStart) <= 0 && $end_date->compare($end_date, $eventEnd) >= 0) {
         // add temporarily moved Event Start and End dates to returnArray
         $transferredEvent = array($eventStart, $eventEnd);
     }
     // return array with event start and end dates for given period (positive case)
     // or an empty array (negative case)
     return $transferredEvent;
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:65,代码来源:calendar.class.php

示例2: CDate

}
// Output the PDF
// make the PDF file
if ($project_id != 0) {
    $sql = "SELECT project_name FROM projects WHERE project_id={$project_id}";
    $pname = db_loadResult($sql);
} else {
    $pname = $AppUI->_('All Projects');
}
if ($err = db_error()) {
    $AppUI->setMsg($err, UI_MSG_ERROR);
    $AppUI->redirect();
}
$date = new CDate();
$next_week = new CDate($date);
$next_week->addSpan(new Date_Span(array(7, 0, 0, 0)));
$hasResources = $AppUI->isActiveModule('resources');
$perms =& $AppUI->acl();
if ($hasResources) {
    $hasResources = $perms->checkModule('resources', 'view');
}
// Build the data to go into the table.
$pdfdata = array();
$columns = array();
$columns[] = $AppUI->_('Task Name');
$columns[] = $AppUI->_('Owner');
$columns[] = $AppUI->_('Assigned Users');
if ($hasResources) {
    $columns[] = $AppUI->_('Assigned Resources');
}
$columns[] = $AppUI->_('Finish Date');
开发者ID:kaz190,项目名称:dotproject,代码行数:31,代码来源:overdue.php

示例3: clash_process

function clash_process()
{
    global $AppUI, $do_include;
    $obj =& new CEvent();
    $obj->bind($_SESSION['add_event_post']);
    $attendees = $_SESSION['add_event_attendees'];
    $users = array();
    if (isset($attendees) && $attendees) {
        $users = explode(',', $attendees);
    }
    array_push($users, $obj->event_owner);
    // First remove any duplicates
    $users = array_unique($users);
    // Now remove any null entries, so implode doesn't create a dud SQL
    // Foreach is safer as it works on a copy of the array.
    foreach ($users as $key => $user) {
        if (!$user) {
            unset($users[$key]);
        }
    }
    $start_date =& new CDate($_POST['event_start_date'] . "000000");
    $end_date =& new CDate($_POST['event_end_date'] . "235959");
    // First find any events in the range requested.
    $event_list = $obj->getEventsInWindow($start_date->format(FMT_DATETIME_MYSQL), $end_date->format(FMT_DATETIME_MYSQL), (int) ($_POST['start_time'] / 100), (int) ($_POST['end_time'] / 100), $users);
    $event_start_date =& new CDate($_POST['event_start_date'] . $_POST['start_time']);
    $event_end_date =& new CDate($_POST['event_end_date'] . $_POST['end_time']);
    if (!$event_list || !count($event_list)) {
        // First available date/time is OK, seed addEdit with the details.
        $obj->event_start_date = $event_start_date->format(FMT_DATETIME_MYSQL);
        $obj->event_end_date = $event_end_date->format(FMT_DATETIME_MYSQL);
        $_SESSION['add_event_post'] = get_object_vars($obj);
        $AppUI->setMsg('No clashes in suggested timespan', UI_MSG_OK);
        $_SESSION['event_is_clash'] = true;
        $_GET['event_id'] = $obj->event_id;
        $do_include = DP_BASE_DIR . "/modules/calendar/addedit.php";
        return;
    }
    // Now we grab the events, in date order, and compare against the
    // required start and end times.
    // Working in 30 minute increments from the start time, and remembering
    // the end time stipulation, find the first hole in the times.
    // Determine the duration in hours/minutes.
    $start_hour = (int) ($_POST['start_time'] / 10000);
    $start_minutes = (int) ($_POST['start_time'] % 10000 / 100);
    $start_time = $start_hour * 60 + $start_minutes;
    $end_hour = (int) ($_POST['end_time'] / 10000);
    $end_minutes = (int) ($_POST['end_time'] % 10000 / 100);
    $end_time = $end_hour * 60 + $end_minutes - $_POST['duration'];
    // First, build a set of "slots" that give us the duration
    // and start/end times we need
    $first_day = $start_date->format('%E');
    $end_day = $end_date->format('%E');
    $days_between = $end_day + 1 - $first_day;
    $oneday =& new Date_Span(array(1, 0, 0, 0));
    $slots = array();
    $slot_count = 0;
    $first_date = new CDate($start_date);
    for ($i = 0; $i < $days_between; $i++) {
        if ($first_date->isWorkingDay()) {
            $slots[$i] = array();
            for ($j = $start_time; $j <= $end_time; $j += 30) {
                $slot_count++;
                $slots[$i][] = array('date' => $first_date->format('%Y-%m-%d'), 'start_time' => $j, 'end_time' => $j + $_POST['duration'], 'committed' => false);
            }
        }
        $first_date->addSpan($oneday);
    }
    // Now process the events list
    foreach ($event_list as $event) {
        $sdate = new CDate($event['event_start_date']);
        $edate = new CDate($event['event_end_date']);
        $sday = $sdate->format('%E');
        $day_offset = $sday - $first_day;
        // Now find the slots on that day that match
        list($syear, $smonth, $sday, $shour, $sminute, $ssecond) = sscanf($event['event_start_date'], "%4d-%2d-%2d %2d:%2d:%2d");
        list($eyear, $emonth, $eday, $ehour, $eminute, $esecond) = sscanf($event['event_start_date'], "%4d-%2d-%2d %2d:%2d:%2d");
        $start_mins = $shour * 60 + $sminute;
        $end_mins = $ehour * 60 + $eminute;
        if (isset($slots[$day_offset])) {
            foreach ($slots[$day_offset] as $key => $slot) {
                if ($start_mins <= $slot['end_time'] && $end_mins >= $slot['start_time']) {
                    $slots[$day_offset][$key]['committed'] = true;
                }
            }
        }
    }
    // Third pass through, find the first uncommitted slot;
    foreach ($slots as $day_offset => $day_slot) {
        foreach ($day_slot as $slot) {
            if (!$slot['committed']) {
                $hour = (int) ($slot['start_time'] / 60);
                $min = $slot['start_time'] % 60;
                $ehour = (int) ($slot['end_time'] / 60);
                $emin = $slot['end_time'] % 60;
                $obj->event_start_date = $slot['date'] . " " . sprintf("%02d:%02d:00", $hour, $min);
                $obj->event_end_date = $slot['date'] . " " . sprintf("%02d:%02d:00", $ehour, $emin);
                $_SESSION['add_event_post'] = get_object_vars($obj);
                $AppUI->setMsg('First available time slot', UI_MSG_OK);
                $_SESSION['event_is_clash'] = true;
                $_GET['event_id'] = $obj->event_id;
//.........这里部分代码省略.........
开发者ID:klr2003,项目名称:sourceread,代码行数:101,代码来源:clash.php

示例4: strtok

    $day_word = strtok(" ");
    if ($day_word == $AppUI->_("Day")) {
        $days = $period_value;
    } else {
        if ($day_word == $AppUI->_("Week")) {
            $days = 7 * $period_value;
        } else {
            if ($day_word == $AppUI->_("Month")) {
                $days = 30 * $period_value;
            }
        }
    }
    $start_date = new CDate($ts);
    $end_date = new CDate($ts);
    if ($sign > 0) {
        $end_date->addSpan(new Date_Span("{$days},0,0,0"));
    } else {
        $start_date->subtractSpan(new Date_Span("{$days},0,0,0"));
    }
    $do_report = 1;
} else {
    // create Date objects from the datetime fields
    $start_date = intval($list_start_date) ? new CDate($list_start_date) : new CDate();
    $end_date = intval($list_end_date) ? new CDate($list_end_date) : new CDate();
}
if (!$list_start_date) {
    $start_date->subtractSpan(new Date_Span("14,0,0,0"));
}
$end_date->setTime(23, 59, 59);
?>
<script language="javascript">
开发者ID:n2i,项目名称:xvnkb,代码行数:31,代码来源:tasklist.php

示例5: clash_process

function clash_process()
{
    global $AppUI, $do_include;
    $obj =& new CEvent();
    $obj->bind($_SESSION['add_event_post']);
    $attendees = $_SESSION['add_event_attendees'];
    $users = array();
    if (isset($attendees) && $attendees) {
        $users = explode(',', $attendees);
    }
    array_push($users, $obj->event_owner);
    // First remove any duplicates
    $users = array_unique($users);
    // Now remove any null entries, so implode doesn't create a dud SQL
    // Foreach is safer as it works on a copy of the array.
    foreach ($users as $key => $user) {
        if (!$user) {
            unset($users[$key]);
        }
    }
    // First find any events in the range requested.
    $start_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
    $end_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
    $end_date->addSeconds($_POST['duration'] * 60);
    $final_date = new CDate($_POST['event_end_date'] . $_POST['end_time']);
    $original_event_start = $obj->event_start_date;
    $original_event_end = $obj->event_end_date;
    $user_list = implode(',', $users);
    // Now we grab the events, in date order, and compare against the
    // required start and end times.
    // Working in 30 minute increments from the start time, and remembering
    // the end time stipulation, find the first hole in the times.
    // Determine the duration in hours/minutes.
    $start_hour = (int) ($_POST['start_time'] / 10000);
    $start_minutes = (int) ($_POST['start_time'] % 10000 / 100);
    $start_min_offset = $start_hour * 60 + $start_minutes;
    $end_hour = (int) ($_POST['end_time'] / 10000);
    $end_minutes = (int) ($_POST['end_time'] % 10000 / 100);
    $end_min_offset = $end_hour * 60 + $end_minutes - $_POST['duration'];
    // First, build a set of "slots" that give us the duration
    // and start/end times we need
    $first_day = $start_date->format('%E');
    $end_day = $final_date->format('%E');
    $oneday =& new Date_Span(array(1, 0, 0, 0));
    $slots = array();
    $curr_date = new CDate($start_date);
    $curr_date->setTime(0, 0, 0);
    $inc = intval(dPgetConfig('cal_day_increment')) ? intval(dPgetConfig('cal_day_increment')) : 30;
    for ($i = 0; $i <= $end_day - $first_day; $i++) {
        if ($curr_date->isWorkingDay()) {
            for ($j = $start_min_offset; $j <= $end_min_offset; $j += $inc) {
                $is_committed = false;
                $slot_start_date = new CDate($curr_date);
                $slot_start_date->addSeconds($j * 60);
                $slot_end_date = new CDate($slot_start_date);
                $slot_end_date->addSeconds($_POST['duration'] * 60);
                $obj->event_start_date = $slot_start_date->format('%Y-%m-%d %T');
                $obj->event_end_date = $slot_end_date->format('%Y-%m-%d %T');
                if (!($clash = $obj->checkClash($user_list))) {
                    $_SESSION['add_event_post'] = get_object_vars($obj);
                    $AppUI->setMsg('First available time slot', UI_MSG_OK);
                    $_SESSION['event_is_clash'] = true;
                    $_GET['event_id'] = $obj->event_id;
                    $do_include = DP_BASE_DIR . '/modules/calendar/addedit.php';
                    return;
                }
            }
        }
        $curr_date->addSpan($oneday);
        $curr_date->setTime(0, 0, 0);
    }
    // If we get here we have found no available slots
    $obj->event_start_date = $original_event_start;
    $obj->event_end_date = $original_event_end;
    clear_clash();
    $AppUI->setMsg('No times match your parameters', UI_MSG_ALERT);
    $AppUI->redirect();
}
开发者ID:illuminate3,项目名称:dotproject,代码行数:78,代码来源:clash.php


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