本文整理汇总了PHP中DateTimeValue::format方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::format方法的具体用法?PHP DateTimeValue::format怎么用?PHP DateTimeValue::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeValue
的用法示例。
在下文中一共展示了DateTimeValue::format方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExecuteQuery
function ExecuteQuery(){
$this->data = array();
$parameters = $this->getParameters();
foreach ($parameters as $p){
$value = $p->getValue();
$date = new DateTimeValue(mktime(12,0,0,$p->getId(),1,2008));
$this->data['values'][0]['labels'][] = $date->format("F");
$this->data['values'][0]['values'][] = (int)$value;
$this->data['values'][1]['labels'][] = $date->format("F");
$this->data['values'][1]['values'][] = 10000;
} // foreach
$this->data['values'][0]['name'] = lang('current');
$this->data['values'][1]['name'] = lang('budgeted');
}
示例2: ExecuteQuery
function ExecuteQuery()
{
$this->data = array();
$parameters = $this->getParameters();
$this->acum = 0;
$this->acumExec = 0;
foreach ($parameters as $p) {
$value = $p->getValue();
$id = $p->getId();
$series = 0;
if ($id > 1000) {
$series = 1;
$id = $id % 1000;
$this->acum += (int) $value;
} else {
$this->acumExec += (int) $value;
}
$date = new DateTimeValue(mktime(12, 0, 0, $id, 1, 2008));
$this->data['values'][$series]['labels'][] = $date->format("F");
$this->data['values'][$series]['values'][] = (int) $value;
}
// foreach
$this->data['values'][0]['name'] = lang('executed');
$this->data['values'][1]['name'] = lang('budgeted');
}
示例3: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $tags = '', $project = null, $archived = false)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
//permission check
$permissions = ' AND ( ' . permissions_sql_for_listings(ProjectEvents::instance(), ACCESS_LEVEL_READ, logged_user()) . ')';
if ($project instanceof Project) {
$pids = $project->getAllSubWorkspacesQuery(!$archived);
$wsstring = " AND " . self::getWorkspaceString($pids);
} else {
$wsstring = "";
}
if (isset($tags) && $tags && $tags != '') {
$tag_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` IN (" . DB::escape($tags) . ") AND `" . TABLE_PREFIX . "project_events`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = 'ProjectEvents') ";
} else {
$tag_str = "";
}
$invited = " AND `id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `user_id` = " . logged_user()->getId() . ")";
if ($archived) {
$archived_cond = " AND `archived_by_id` <> 0";
} else {
$archived_cond = " AND `archived_by_id` = 0";
}
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\t((\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS ON THE ACTUAL DAY IT'S SET FOR (ONE TIME EVENTS)\n\t\t\t\t-- \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \n\t\t\t\t\tAND `start` < '{$end_date_str}' \n\t\t\t\t) \n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS REGULAR REPEATING EVENTS - DAILY, WEEKLY, MONTHLY, OR YEARLY.\n\t\t\t\t-- \n\t\t\t\tOR \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t(\t\t\t\t\t\t\t\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\t\t\n\t\t\t\t)\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS SET TO BE A CERTAIN DAY OF THE WEEK IN A CERTAIN WEEK EVERY CERTAIN AMOUNT OF MONTHS\n\t\t\t\t-- \n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tDATE(`start`) <= '{$start_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_h` = 1 \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_dow` = DAYOFWEEK('{$start_date_str}') \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_wnum` + {$week_of_first_day} - 1 = WEEK('{$start_date_str}', 3) \n\t\t\t\t\tAND\n\t\t\t\t\tMOD( PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m')), `repeat_mjump`) = 0\n\t\t\t\t)\t\t\t\t\n\t\t\t)\n\t\t\t{$wsstring}\n\t\t\t{$permissions} {$invited}\n\t\t\t{$tag_str} {$archived_cond} )";
$result_events = self::findAll(array('conditions' => $conditions, 'order' => '`start`'));
// Find invitations for events and logged user
ProjectEvents::addInvitations($result_events);
return $result_events;
}
示例4: DateTimeValue
$eventid = $event->getId();
$event_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone());
$event_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone());
// make the event subjects links or not according to the variable $whole_day in gatekeeper.php
if (!$private && $count <= 3) {
$output .= "<div class='event_block' style='z-index:1000;'>";
if ($subject == "") {
$subject = "[" . lang('CAL_NO_SUBJECT') . "]";
}
$subject_toshow = mb_strlen($subject) < $to_show_len ? $subject : mb_substr($subject, 0, $to_show_len - 3) . "...";
$output .= "<span id='o_ev_div_" . $event->getId() . "'>";
$output .= "<a class=\"internalLink link-ico ico-event\" style='vertical-align:bottom;' href='" . get_url('event', 'view', array('id' => $event->getId())) . "' onclick=\"og.disableEventPropagation(event);\" >";
$output .= $subject_toshow . "</a>";
$output .= '</span>';
$output .= "</div>";
$tip_text = str_replace("\r", '', $event->getTypeId() == 2 ? lang('CAL_FULL_DAY') : $event_start->format($use_24_hours ? 'G:i' : 'g:i A') . ' - ' . $event_duration->format($use_24_hours ? 'G:i' : 'g:i A') . (trim(clean($event->getDescription())) != '' ? '<br><br>' . clean($event->getDescription()) : ''));
$tip_text = str_replace("\n", '<br>', $tip_text);
if (strlen_utf($tip_text) > 200) {
$tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
}
?>
<script >
addTip('o_ev_div_<?php
echo $event->getId();
?>
', '<i>' + lang('event') + '</i> - '+<?php
echo json_encode(clean($event->getSubject()));
?>
, <?php
echo json_encode($tip_text);
?>
示例5: generateICalInfo
function generateICalInfo($events, $calendar_name, $user = null) {
if ($user == null) $user = logged_user();
$ical_info = '';
$ical_info .= "BEGIN:VCALENDAR\r\n";
$ical_info .= "VERSION:2.0\r\n";
$ical_info .= "PRODID:PHP\r\n";
$ical_info .= "METHOD:REQUEST\r\n";
$ical_info .= "X-WR-CALNAME:$calendar_name\r\n";
// timezone info
$tz = ($user->getTimezone() < 0 ? "-":"+").str_pad(abs($user->getTimezone())*100, 4, '0', STR_PAD_LEFT);
$tz_desc = $user->getTimezone() > 0 ? lang("timezone gmt +".$user->getTimezone()) : lang("timezone gmt ".$user->getTimezone());
$ical_info .= "BEGIN:VTIMEZONE\r\n";
$ical_info .= "TZID:$tz_desc\r\n";
$ical_info .= "BEGIN:STANDARD\r\n";
$ical_info .= "TZOFFSETFROM:$tz\r\n";
$ical_info .= "TZOFFSETTO:$tz\r\n";
$ical_info .= "END:STANDARD\r\n";
$ical_info .= "END:VTIMEZONE\r\n";
foreach ($events as $event) {
$ical_info .= "BEGIN:VEVENT\r\n";
$event_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * $user->getTimezone());
$event_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * $user->getTimezone());
$startNext = new DateTimeValue($event_start->getTimestamp());
$startNext->add('d', 1);
if ($event->getTypeId() == 2) $ical_info .= "DTSTART;VALUE=DATE:" . $event_start->format('Ymd') ."\r\n";
else $ical_info .= "DTSTART:" . $event_start->format('Ymd') ."T". $event_start->format('His') ."\r\n";
if ($event->getTypeId() == 2) $ical_info .= "DTEND;VALUE=DATE:" . $startNext->format('Ymd') ."\r\n";
else $ical_info .= "DTEND:" . $event_duration->format('Ymd') ."T". $event_duration->format('His') ."\r\n";
$uid = $event->getId() . "@";
$url = str_replace('http://', '', ROOT_URL);
$uid .= str_replace('www.', '', $url);
$description = str_replace(array(chr(13).chr(10), chr(13), chr(10)),'\n', $event->getDescription());
$ical_info .= "DESCRIPTION:$description\r\n";
$ical_info .= "SUMMARY:" . $event->getSubject() . "\r\n";
$ical_info .= "UID:$uid\r\n";
$ical_info .= "SEQUENCE:0\r\n";
$ical_info .= "DTSTAMP:".$event->getUpdatedOn()->format('Ymd').'T'.$event->getUpdatedOn()->format('His')."\r\n";
$invitations = $event->getInvitations();
if (is_array($invitations) && array_var($invitations, $user->getId())) {
$inv = array_var($invitations, $user->getId());
$inv->getInvitationState();
if ($inv->getInvitationState() == 1) $ical_info .= "STATUS:CONFIRMED\r\n";
else if ($inv->getInvitationState() == 2) $ical_info .= "STATUS:CANCELLED\r\n";
else $ical_info .= "STATUS:TENTATIVE\r\n";
}
$rrule = '';
if ($event->getRepeatD() > 0 || $event->getRepeatM() > 0 || $event->getRepeatY() > 0 || $event->getRepeatForever() > 0) {
$rrule_ok = true;
if ($event->getRepeatD() > 0) {
if ($event->getRepeatD() % 7 == 0) {
$freq = "FREQ=WEEKLY;";
$interval = "INTERVAL=".($event->getRepeatD() / 7);
} else {
$freq = "FREQ=DAILY;";
$interval = "INTERVAL=".$event->getRepeatD();
}
} else if ($event->getRepeatM() > 0) {
$freq = "FREQ=MONTHLY;";
$interval = "INTERVAL=".$event->getRepeatM();
} else if ($event->getRepeatY() > 0) {
$freq = "FREQ=YEARLY;";
$interval = "INTERVAL=".$event->getRepeatY();
} else {
$rrule_ok = false;
}
$until = '';
$count = '';
if (!$event->getRepeatForever() && $event->getRepeatNum() > 0) $count = ";COUNT=".$event->getRepeatNum();
else if (!$event->getRepeatForever() && $event->getRepeatEnd()) $until = ";UNTIL=".$event->getRepeatEnd()->format('Ymd').'T'.$event->getRepeatEnd()->format('His');
if ($rrule_ok) $rrule = "RRULE:$freq$interval$count$until\r\n";
}
if ($event->getRepeatH() > 0) {
"RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=1TU";
$interval = "INTERVAL=".$event->getRepeatMjump();
switch ($event->getRepeatDow()) {
case 1: $day = "SU"; break;
case 2: $day = "MO"; break;
case 3: $day = "TU"; break;
case 4: $day = "WE"; break;
case 5: $day = "TH"; break;
case 6: $day = "FR"; break;
case 7: $day = "SA"; break;
default: $day = "MO"; break;
}
$byday = "BYDAY=" . $event->getRepeatWnum() . $day;
$rrule = "RRULE:FREQ=MONTHLY;$interval;$byday\r\n";
}
$ical_info .= $rrule;
$ical_info .= "END:VEVENT\r\n";
}
//.........这里部分代码省略.........
示例6: get_updated_event_data
private function get_updated_event_data($event) {
$new_start = new DateTimeValue($event->getStart()->getTimestamp() + logged_user()->getTimezone() * 3600);
$new_duration = new DateTimeValue($event->getDuration()->getTimestamp() + logged_user()->getTimezone() * 3600);
$ev_data = array (
'start' => $new_start->format(user_config_option('time_format_use_24') ? "G:i" : "g:i A"),
'end' => $new_duration->format(user_config_option('time_format_use_24') ? "G:i" : "g:i A"),
'' => clean($event->getObjectName()),
);
return array("ev_data" => $ev_data);
}
示例7: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $user_filter = null, $inv_state = null)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
$user = null;
if ($user_filter > 0) {
$user = Contacts::findById($user_filter);
}
if ($user_filter != -1 && !$user instanceof Contact) {
$user = logged_user();
}
$invited = "";
if ($user instanceof Contact) {
$invited = " AND o.`id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `contact_id` = " . $user->getId() . ")";
}
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\r\n\t\t\tAND (type_id=2 OR type_id=1 AND `duration` > `start`)\r\n\t\t\tAND \r\n\t\t\t(\r\n\t\t\t (\r\n\t\t\t\t(\r\n\t\t\t\t\t`repeat_h` = 0\r\n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \r\n\t\t\t\t\tAND `start` < '{$end_date_str}' \r\n\t\t\t\t) \r\n\t\t\t\tOR \r\n\t\t\t\t(\r\n\t\t\t\t\toriginal_event_id = 0\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t`repeat_h` = 0 \r\n\t\t\t\t\tAND\r\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t(\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t)\t\t\r\n\t\t\t\t)\r\n\t\t\t\tOR\r\n\t\t\t\t(\r\n\t\t\t\t\toriginal_event_id = 0\r\n\t\t\t\t\tAND\r\n\t\t\t\t\tDATE(`start`) <= '{$end_date_str}'\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t`repeat_h` = 1 \t\t\t\t\t\r\n\t\t\t\t\tAND\r\n\t\t\t\t\tMOD( ABS(PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m'))), `repeat_mjump`) = 0\t\t\t\t\t\r\n\t\t\t\t)\r\n\t\t\t )\r\n\t\t\t {$invited}\r\n\t\t\t)";
$result_events = self::instance()->listing(array("order" => 'start', "order_dir" => 'ASC', "extra_conditions" => $conditions))->objects;
// Find invitations for events and logged user
if (!($user_filter == null && $inv_state == null) && $user_filter != -1) {
ProjectEvents::addInvitations($result_events, $user->getId());
foreach ($result_events as $k => $event) {
$inv = $event->getInvitations();
if (!is_array($inv)) {
if ($inv == null || trim($inv_state) != '-1' && !strstr($inv_state, '' . $inv->getInvitationState()) && $inv->getContactId() == logged_user()->getId()) {
unset($result_events[$k]);
}
} else {
if (count($inv) > 0) {
foreach ($inv as $key => $v) {
if ($v == null || trim($inv_state) != '-1' && !strstr($inv_state, '' . $v->getInvitationState()) && $v->getContactId() == logged_user()->getId()) {
unset($result_events[$k]);
break;
}
}
} else {
unset($result_events[$k]);
}
}
}
}
return $result_events;
}
示例8: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $tags = '', $project = null, $archived = false)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
$invited = " AND `id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `contact_id` = " . logged_user()->getId() . ")";
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\tAND ((\n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \n\t\t\t\t\tAND `start` < '{$end_date_str}' \n\t\t\t\t) \n\t\t\t\tOR \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t(\t\t\t\t\t\t\t\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n repeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t)\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\t\t\n\t\t\t\t)\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tDATE(`start`) <= '{$start_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_h` = 1 \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_dow` = DAYOFWEEK('{$start_date_str}') \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_wnum` + {$week_of_first_day} - 1 = WEEK('{$start_date_str}', 3) \n\t\t\t\t\tAND\n\t\t\t\t\tMOD( ABS(PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m'))), `repeat_mjump`) = 0\t\t\t\t\t\n\t\t\t\t)\t\t\t\t\n\t\t\t)\n\t\t\t{$invited}\n\t\t)";
//$result_events = self::getContentObjects(active_context(), ObjectTypes::findById(self::instance()->getObjectTypeId()), '`start`', 'ASC', $conditions, null, false, false, $start, $limit);
$result_events = self::instance()->listing(array("order" => 'start', "order_dir" => 'ASC', "extra_conditions" => $conditions, "start" => $start, "limit" => $limit))->objects;
// Find invitations for events and logged user
ProjectEvents::addInvitations($result_events);
return $result_events;
}
示例9: DateTimeValue
$ends_this_week = true;
for ($d = $day_of_week+1; $d < $dow; $d++) {
$results[$d][$task->getId()] = $task;
}
}
}
if (!$ends_this_week && $task->getDueDate() instanceof DateTimeValue) {
for ($d = $day_of_week+1; $d < 7; $d++) {
$results[$d][$task->getId()] = $task;
}
}
}
}
if (!$starts_this_week && $task->getDueDate() instanceof DateTimeValue) {
$due_date = new DateTimeValue($task->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600);
$due_dow = $due_date->format('w') + (user_config_option("start_monday") ? -1 : 0);
for ($dow = 0; $dow < $due_dow; $dow++) {
$dow_ts = mktime(0, 0, 0, $month, $startday + $dow, $year);
if ($task->getStartDate() instanceof DateTimeValue && $task->getStartDate()->getTimestamp() < $dow_ts) {
$results[$dow][$task->getId()] = $task;
}
}
}
}
}
$max_events = max($allday_events_count) == 0 ? 1 : max($allday_events_count);
$alldaygridHeight = $max_events * PX_HEIGHT / 2 + PX_HEIGHT / 2;//Day events container height= all the events plus an extra free space
if($alldaygridHeight > 100){
$alldaygridHeight = 100;
}