本文整理汇总了PHP中calendar_time_representation函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_time_representation函数的具体用法?PHP calendar_time_representation怎么用?PHP calendar_time_representation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_time_representation函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calendar_format_event_time
function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true, $showtime = 0)
{
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if ($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
} else {
$usermidnightend = $usermidnightstart;
}
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if ($event->timeduration) {
// It has a duration
if ($usermidnightstart == $usermidnightend || $event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399) || $event->timestart + $event->timeduration <= $usermidnightstart + 86400) {
// But it's all on the same day
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
$time = $timestart . ' <strong>»</strong> ' . $timeend;
if ($event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399)) {
$time = get_string('allday', 'calendar');
}
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ', ' . $time;
} else {
$eventtime = $time;
}
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
if ($now >= $usermidnightstart && $now < $usermidnightstart + 86400) {
$eventtime = $timestart . ' <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
} else {
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . $timestart . ' <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
}
}
} else {
$time = ' ';
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . trim($time);
} else {
$eventtime = $time;
}
}
if ($event->timestart + $event->timeduration < $now) {
// It has expired
$eventtime = '<span class="dimmed_text">' . str_replace(' href=', ' class="dimmed" href=', $eventtime) . '</span>';
}
return $eventtime;
}
示例2: calendar_format_event_time
/**
* Get event format time
*
* @param calendar_event $event event object
* @param int $now current time in gmt
* @param array $linkparams list of params for event link
* @param bool $usecommonwords the words as formatted date/time.
* @param int $showtime determine the show time GMT timestamp
* @return string $eventtime link/string for event time
*/
function calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime = 0)
{
$starttime = $event->timestart;
$endtime = $event->timestart + $event->timeduration;
if (empty($linkparams) || !is_array($linkparams)) {
$linkparams = array();
}
$linkparams['view'] = 'day';
// OK, now to get a meaningful display...
// Check if there is a duration for this event.
if ($event->timeduration) {
// Get the midnight of the day the event will start.
$usermidnightstart = usergetmidnight($starttime);
// Get the midnight of the day the event will end.
$usermidnightend = usergetmidnight($endtime);
// Check if we will still be on the same day.
if ($usermidnightstart == $usermidnightend) {
// Check if we are running all day.
if ($event->timeduration == DAYSECS) {
$time = get_string('allday', 'calendar');
} else {
// Specify the time we will be running this from.
$datestart = calendar_time_representation($starttime);
$dateend = calendar_time_representation($endtime);
$time = $datestart . ' <strong>»</strong> ' . $dateend;
}
// Set printable representation.
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = html_writer::link($url, $day) . ', ' . $time;
} else {
$eventtime = $time;
}
} else {
// It must spans two or more days.
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation.
if ($now >= $usermidnightstart && $now < $usermidnightstart + DAYSECS) {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = $timestart . ' <strong>»</strong> ' . html_writer::link($url, $dayend) . $timeend;
} else {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = html_writer::link($url, $daystart) . $timestart . ' <strong>»</strong> ';
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
$eventtime .= html_writer::link($url, $dayend) . $timeend;
}
}
} else {
// There is no time duration.
$time = calendar_time_representation($event->timestart);
// Set printable representation.
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
$eventtime = html_writer::link($url, $day) . ', ' . trim($time);
} else {
$eventtime = $time;
}
}
// Check if It has expired.
if ($event->timestart + $event->timeduration < $now) {
$eventtime = '<span class="dimmed_text">' . str_replace(' href=', ' class="dimmed" href=', $eventtime) . '</span>';
}
return $eventtime;
}
示例3: event
/**
* Displays an event
*
* @param calendar_event $event
* @param bool $showactions
* @return string
*/
public function event(calendar_event $event, $showactions = true)
{
global $CFG;
$event = calendar_add_event_metadata($event);
$context = $event->context;
$anchor = html_writer::tag('a', '', array('name' => 'event_' . $event->id));
$table = new html_table();
$table->attributes = array('class' => 'event', 'cellspacing' => '0');
$table->data = array(0 => new html_table_row(), 1 => new html_table_row());
if (!empty($event->icon)) {
$table->data[0]->cells[0] = new html_table_cell($anchor . $event->icon);
} else {
$table->data[0]->cells[0] = new html_table_cell($anchor . $this->output->spacer(array('height' => 16, 'width' => 16, 'br' => true)));
}
$table->data[0]->cells[0]->attributes['class'] .= ' picture';
$table->data[0]->cells[1] = new html_table_cell();
$table->data[0]->cells[1]->attributes['class'] .= ' topic';
if (!empty($event->referer)) {
$table->data[0]->cells[1]->text .= html_writer::tag('div', $event->referer, array('class' => 'referer'));
} else {
$table->data[0]->cells[1]->text .= html_writer::tag('div', format_string($event->name, false, array('context' => $context)), array('class' => 'name'));
}
if (!empty($event->courselink)) {
$table->data[0]->cells[1]->text .= html_writer::tag('div', $event->courselink, array('class' => 'course'));
}
// Show subscription source if needed.
if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
if (!empty($event->subscription->url)) {
$source = html_writer::link($event->subscription->url, get_string('subsource', 'calendar', $event->subscription));
} else {
// File based ical.
$source = get_string('subsource', 'calendar', $event->subscription);
}
$table->data[0]->cells[1]->text .= html_writer::tag('div', $source, array('class' => 'subscription'));
}
if (!empty($event->time)) {
$table->data[0]->cells[1]->text .= html_writer::tag('span', $event->time, array('class' => 'date'));
} else {
$table->data[0]->cells[1]->text .= html_writer::tag('span', calendar_time_representation($event->timestart), array('class' => 'date'));
}
$table->data[1]->cells[0] = new html_table_cell(' ');
$table->data[1]->cells[0]->attributes['class'] .= 'side';
$table->data[1]->cells[1] = new html_table_cell(format_text($event->description, $event->format, array('context' => $context)));
$table->data[1]->cells[1]->attributes['class'] .= ' description';
if (isset($event->cssclass)) {
$table->data[1]->cells[1]->attributes['class'] .= ' ' . $event->cssclass;
}
if (calendar_edit_event_allowed($event) && $showactions) {
if (empty($event->cmid)) {
$editlink = new moodle_url(CALENDAR_URL . 'event.php', array('action' => 'edit', 'id' => $event->id));
$deletelink = new moodle_url(CALENDAR_URL . 'delete.php', array('id' => $event->id));
if (!empty($event->calendarcourseid)) {
$editlink->param('course', $event->calendarcourseid);
$deletelink->param('course', $event->calendarcourseid);
}
} else {
$editlink = new moodle_url('/course/mod.php', array('update' => $event->cmid, 'return' => true, 'sesskey' => sesskey()));
$deletelink = null;
}
$commands = html_writer::start_tag('div', array('class' => 'commands'));
$commands .= html_writer::start_tag('a', array('href' => $editlink));
$commands .= html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'), 'alt' => get_string('tt_editevent', 'calendar'), 'title' => get_string('tt_editevent', 'calendar')));
$commands .= html_writer::end_tag('a');
if ($deletelink != null) {
$commands .= html_writer::start_tag('a', array('href' => $deletelink));
$commands .= html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/delete'), 'alt' => get_string('tt_deleteevent', 'calendar'), 'title' => get_string('tt_deleteevent', 'calendar')));
$commands .= html_writer::end_tag('a');
}
$commands .= html_writer::end_tag('div');
$table->data[1]->cells[1]->text .= $commands;
}
return html_writer::table($table);
}
示例4: friendly_datetime
/**
* Return friendly text date (e.g. "Today", "Tomorrow") in a <time> tag
* @return string
*/
public function friendly_datetime($time)
{
$timetext = \calendar_day_representation($time);
$timetext .= ', ' . \calendar_time_representation($time);
$datetime = date(DateTime::W3C, $time);
return html_writer::tag('time', $timetext, array('datetime' => $datetime));
}
示例5: event
/**
* Displays an event
*
* @param calendar_event $event
* @param bool $showactions
* @return string
*/
public function event(calendar_event $event, $showactions = true)
{
global $CFG;
$event = calendar_add_event_metadata($event);
$context = $event->context;
$output = '';
if (!empty($event->icon)) {
$output .= $event->icon;
} else {
$output .= $this->output->spacer(array('height' => 16, 'width' => 16));
}
if (!empty($event->referer)) {
$output .= $this->output->heading($event->referer, 3, array('class' => 'referer'));
} else {
$output .= $this->output->heading(format_string($event->name, false, array('context' => $context)), 3, array('class' => 'name'));
}
if (!empty($event->courselink)) {
$output .= html_writer::tag('div', $event->courselink, array('class' => 'course'));
}
// Show subscription source if needed.
if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
if (!empty($event->subscription->url)) {
$source = html_writer::link($event->subscription->url, get_string('subsource', 'calendar', $event->subscription));
} else {
// File based ical.
$source = get_string('subsource', 'calendar', $event->subscription);
}
$output .= html_writer::tag('div', $source, array('class' => 'subscription'));
}
if (!empty($event->time)) {
$output .= html_writer::tag('span', $event->time, array('class' => 'date'));
} else {
$output .= html_writer::tag('span', calendar_time_representation($event->timestart), array('class' => 'date'));
}
$eventdetailshtml = '';
$eventdetailsclasses = '';
$eventdetailshtml .= format_text($event->description, $event->format, array('context' => $context));
$eventdetailsclasses .= 'description';
if (isset($event->cssclass)) {
$eventdetailsclasses .= ' ' . $event->cssclass;
}
$output .= html_writer::tag('div', $eventdetailshtml, array('class' => $eventdetailsclasses));
if (calendar_edit_event_allowed($event) && $showactions) {
if (empty($event->cmid)) {
$editlink = new moodle_url(CALENDAR_URL . 'event.php', array('action' => 'edit', 'id' => $event->id));
$deletelink = new moodle_url(CALENDAR_URL . 'delete.php', array('id' => $event->id));
if (!empty($event->calendarcourseid)) {
$editlink->param('course', $event->calendarcourseid);
$deletelink->param('course', $event->calendarcourseid);
}
} else {
$editlink = new moodle_url('/course/mod.php', array('update' => $event->cmid, 'return' => true, 'sesskey' => sesskey()));
$deletelink = null;
}
$commands = html_writer::start_tag('div', array('class' => 'commands'));
$commands .= html_writer::start_tag('a', array('href' => $editlink));
$commands .= html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'), 'alt' => get_string('tt_editevent', 'calendar'), 'title' => get_string('tt_editevent', 'calendar')));
$commands .= html_writer::end_tag('a');
if ($deletelink != null) {
$commands .= html_writer::start_tag('a', array('href' => $deletelink));
$commands .= html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/delete'), 'alt' => get_string('tt_deleteevent', 'calendar'), 'title' => get_string('tt_deleteevent', 'calendar')));
$commands .= html_writer::end_tag('a');
}
$commands .= html_writer::end_tag('div');
$output .= $commands;
}
return html_writer::tag('div', $output, array('class' => 'event', 'id' => 'event_' . $event->id));
}
示例6: bigbluebuttonbn_process_post_save
/**
* Runs any processes that must be run
* after a bigbluebuttonbn insert/update
*
* @global object
* @param object $bigbluebuttonbn BigBlueButtonBN form data
* @return void
**/
function bigbluebuttonbn_process_post_save(&$bigbluebuttonbn)
{
global $DB, $CFG, $USER;
// Now that an id was assigned, generate and set the meetingid property based on
// [Moodle Instance + Activity ID + BBB Secret] (but only for new activities)
if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) {
$bigbluebuttonbn_meetingid = sha1($CFG->wwwroot . $bigbluebuttonbn->id . bigbluebuttonbn_get_cfg_shared_secret());
$DB->set_field('bigbluebuttonbn', 'meetingid', $bigbluebuttonbn_meetingid, array('id' => $bigbluebuttonbn->id));
$action = get_string('mod_form_field_notification_msg_created', 'bigbluebuttonbn');
} else {
$action = get_string('mod_form_field_notification_msg_modified', 'bigbluebuttonbn');
}
// Add evento to the calendar when if openingtime is set
if (isset($bigbluebuttonbn->openingtime) && $bigbluebuttonbn->openingtime) {
$event = new stdClass();
$event->name = $bigbluebuttonbn->name;
$event->courseid = $bigbluebuttonbn->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'bigbluebuttonbn';
$event->instance = $bigbluebuttonbn->id;
$event->timestart = $bigbluebuttonbn->openingtime;
if ($bigbluebuttonbn->closingtime) {
$event->durationtime = $bigbluebuttonbn->closingtime - $bigbluebuttonbn->openingtime;
} else {
$event->durationtime = 0;
}
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
calendar_event::create($event);
}
} else {
$DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id));
}
if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) {
// Prepare message
$msg = new stdClass();
/// Build the message_body
$msg->action = $action;
$msg->activity_type = "";
$msg->activity_title = $bigbluebuttonbn->name;
/// Add the meeting details to the message_body
$msg->action = ucfirst($action);
$msg->activity_description = "";
if (!empty($bigbluebuttonbn->intro)) {
$msg->activity_description = trim($bigbluebuttonbn->intro);
}
$msg->activity_openingtime = "";
if ($bigbluebuttonbn->openingtime) {
$date = new stdClass();
$date->day = calendar_day_representation($bigbluebuttonbn->openingtime);
$date->time = calendar_time_representation($bigbluebuttonbn->openingtime);
$msg->activity_openingtime = get_string('email_date', 'bigbluebuttonbn', $date);
}
$msg->activity_closingtime = "";
if ($bigbluebuttonbn->closingtime) {
$date = new stdClass();
$date->day = calendar_day_representation($bigbluebuttonbn->closingtime);
$date->time = calendar_time_representation($bigbluebuttonbn->closingtime);
$msg->activity_closingtime = get_string('email_date', 'bigbluebuttonbn', $date);
}
$msg->activity_owner = fullname($USER);
$message_text = get_string('email_body_notification', 'bigbluebuttonbn', $msg);
// Send notification to all users enrolled
bigbluebuttonbn_send_notification($USER, $bigbluebuttonbn, $message_text);
}
}
示例7: print_event
function print_event($ev, $param, $val, $allowededit)
{
echo '<tr>';
if ($allowededit) {
$imgedit = '<a href="event.php?' . $param . '=' . $val . '&action=edit&eventid=' . $ev->id . '"><img src="img/edit.gif" alt="edit" /></a>';
$imgdel = '<a href="event.php?' . $param . '=' . $val . '&action=delete&eventid=' . $ev->id . '"><img src="img/delete.gif" alt="delete" /></a>';
} else {
$imgedit = $imgdel = '';
}
$time = usergetdate($ev->timestart);
$timeend = usergetdate($ev->timestart + $ev->timeduration);
echo '<td style="text-align: left;">' . $imgedit . $imgdel;
$ev->time = calendar_format_event_time($ev, time(), '', false);
if (!empty($ev->time)) {
echo '<span class="date">' . $ev->time . '</span>';
} else {
echo '<span class="date">' . calendar_time_representation($ev->timestart) . '</span>';
}
echo '</td><td>' . $ev->location . '</td>';
echo '</tr>';
}
示例8: calendar_format_event_time
/**
* Get event format time
*
* @param calendar_event $event event object
* @param int $now current time in gmt
* @param array $linkparams list of params for event link
* @param bool $usecommonwords the words as formatted date/time.
* @param int $showtime determine the show time GMT timestamp
* @return string $eventtime link/string for event time
*/
function calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime=0) {
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
}
else {
$usermidnightend = $usermidnightstart;
}
if (empty($linkparams) || !is_array($linkparams)) {
$linkparams = array();
}
$linkparams['view'] = 'day';
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if($event->timeduration) {
// It has a duration
if($usermidnightstart == $usermidnightend ||
($event->timestart == $usermidnightstart) && ($event->timeduration == 86400 || $event->timeduration == 86399) ||
($event->timestart + $event->timeduration <= $usermidnightstart + 86400)) {
// But it's all on the same day
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
$time = $timestart.' <strong>»</strong> '.$timeend;
if ($event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399)) {
$time = get_string('allday', 'calendar');
}
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = html_writer::link($url, $day).', '.$time;
} else {
$eventtime = $time;
}
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords).', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords).', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
if ($now >= $usermidnightstart && $now < ($usermidnightstart + 86400)) {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = $timestart.' <strong>»</strong> '.html_writer::link($url, $dayend).$timeend;
} else {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = html_writer::link($url, $daystart).$timestart.' <strong>»</strong> ';
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $startdate['mday'], $startdate['mon'], $startdate['year']);
$eventtime .= html_writer::link($url, $dayend).$timeend;
}
}
} else {
$time = calendar_time_representation($event->timestart);
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $startdate['mday'], $startdate['mon'], $startdate['year']);
$eventtime = html_writer::link($url, $day).', '.trim($time);
} else {
$eventtime = $time;
}
}
if($event->timestart + $event->timeduration < $now) {
// It has expired
$eventtime = '<span class="dimmed_text">'.str_replace(' href=', ' class="dimmed" href=', $eventtime).'</span>';
}
return $eventtime;
}
示例9: calendar_format_event_time
function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true)
{
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if ($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
} else {
$usermidnightend = $usermidnightstart;
}
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if ($event->timestart + $event->timeduration < $now) {
// It has expired, so we don't care about duration
$day = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
$time = calendar_time_representation($event->timestart + $event->timeduration);
// This var always has the printable time representation
$eventtime = '<span class="dimmed_text"><a class="dimmed" href="' . calendar_get_link_href(CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . '">' . $day . '</a> (' . $time . ')</span>';
} else {
if ($event->timeduration) {
// It has a duration
if ($usermidnightstart == $usermidnightend) {
// But it's all on the same day
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ' (' . $timestart . ' <strong>»</strong> ' . $timeend . ')';
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . ' (' . $timestart . ') <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ' (' . $timeend . ')';
}
} else {
// It's an "instantaneous" event
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$time = calendar_time_representation($event->timestart);
// Set printable representation
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . ' (' . $time . ')';
}
}
return $eventtime;
}
示例10: meeting_times
/**
* Meeting times.
*
* @param $times
* @return string
*/
public function meeting_times($times)
{
$startday = calendar_day_representation($times->start);
$endday = calendar_day_representation($times->end);
$endtime = calendar_time_representation($times->end);
$startyear = userdate($times->start, '%y');
$endyear = userdate($times->end, '%y');
$startmonth = userdate($times->start, '%m');
$endmonth = userdate($times->end, '%m');
$openended = date('Y-m-d', $times->end) === '3000-01-01';
$startiscurrentyear = $startyear === userdate(time(), '%y');
if ($startiscurrentyear && ($openended || $startyear === $endyear)) {
$datesstr = $this->datetime($times->start);
} else {
$visualstart = userdate($times->start, get_string('strftimedatetime', 'langconfig'));
$datesstr = $this->datetime($times->start, $visualstart);
}
if ($startday === $endday && $startmonth === $endmonth && $startyear === $endyear) {
$datesstr .= ' - ' . $this->datetime($times->end, $endtime);
} else {
if ($openended) {
$datesstr .= ' (' . get_string('openended', 'mod_collaborate') . ')';
} else {
if ($startyear === $endyear) {
$datesstr .= ' - ' . $this->datetime($times->end);
} else {
$visualend = userdate($times->end, get_string('strftimedatetime', 'langconfig'));
$datesstr .= ' - ' . $this->datetime($times->end, $visualend);
}
}
}
return $datesstr;
}