當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTimeValue::setHour方法代碼示例

本文整理匯總了PHP中DateTimeValue::setHour方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeValue::setHour方法的具體用法?PHP DateTimeValue::setHour怎麽用?PHP DateTimeValue::setHour使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateTimeValue的用法示例。


在下文中一共展示了DateTimeValue::setHour方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getEventLimits

function getEventLimits($event, $date, &$event_start, &$event_duration, &$end_modified)
{
    $end_modified = false;
    if ($event instanceof ProjectEvent) {
        $event_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone());
        $event_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone());
    } else {
        if ($event instanceof ProjectTask) {
            /* @var $event ProjectTask */
            $work_day_start = new DateTimeValue($date->getTimestamp());
            $wsd = user_config_option('work_day_start_time');
            $work_day_start->setHour(substr($wsd, 0, strpos($wsd, ':')));
            $work_day_start->setMinute(substr($wsd, strpos($wsd, ':') + 1));
            if ($event->getStartDate() instanceof DateTimeValue) {
                $event_start = new DateTimeValue($event->getStartDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
            } else {
                if ($event->getTimeEstimate() > 0 && $event->getDueDate() instanceof DateTimeValue) {
                    $event_start = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
                    $event_start->advance($event->getTimeEstimate() * -60);
                } else {
                    $event_start = $work_day_start;
                }
            }
            $work_day_end = new DateTimeValue($date->getTimestamp());
            $wed = user_config_option('work_day_end_time');
            $work_day_end->setHour(substr($wed, 0, strpos($wed, ':')));
            $work_day_end->setMinute(substr($wed, strpos($wed, ':') + 1));
            if ($event->getDueDate() instanceof DateTimeValue) {
                $event_duration = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
            } else {
                if ($event->getTimeEstimate() > 0 && $event->getStartDate() instanceof DateTimeValue) {
                    $event_duration = new DateTimeValue($event_start->getTimestamp());
                    $event_duration->advance($event->getTimeEstimate() * 60);
                } else {
                    $event_duration = $work_day_end;
                }
            }
        }
    }
    $tomorrow = new DateTimeValue($date->getTimestamp());
    $tomorrow->add('d', 1);
    if ($event_duration->getTimestamp() > $tomorrow->getTimestamp()) {
        $event_duration = new DateTimeValue($tomorrow->getTimestamp());
        $end_modified = true;
    }
    if ($event_start->getTimestamp() < $date->getTimestamp()) {
        if (!$event->isRepetitive()) {
            $event_start = new DateTimeValue($date->getTimestamp());
        } else {
            $event_start->setDay($date->getDay());
            $event_start->setMonth($date->getMonth());
            $event_start->setYear($date->getYear());
        }
    }
}
開發者ID:abhinay100,項目名稱:feng_app,代碼行數:55,代碼來源:calendar.php


注:本文中的DateTimeValue::setHour方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。