本文整理汇总了PHP中PhabricatorTime::getTodayMidnightDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorTime::getTodayMidnightDateTime方法的具体用法?PHP PhabricatorTime::getTodayMidnightDateTime怎么用?PHP PhabricatorTime::getTodayMidnightDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorTime
的用法示例。
在下文中一共展示了PhabricatorTime::getTodayMidnightDateTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildCalendarDayView
private function buildCalendarDayView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorCalendarApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$midnight = PhabricatorTime::getTodayMidnightDateTime($viewer);
$week_end = clone $midnight;
$week_end = $week_end->modify('+3 days');
$range_start = $midnight->format('U');
$range_end = $week_end->format('U');
$events = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withDateRange($range_start, $range_end)->withInvitedPHIDs(array($user->getPHID()))->withIsCancelled(false)->needRSVPs(array($viewer->getPHID()))->execute();
$event_views = array();
foreach ($events as $event) {
$viewer_is_invited = $event->isRSVPInvited($viewer->getPHID());
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $event, PhabricatorPolicyCapability::CAN_EDIT);
$epoch_min = $event->getStartDateTimeEpoch();
$epoch_max = $event->getEndDateTimeEpoch();
$event_view = id(new AphrontCalendarEventView())->setCanEdit($can_edit)->setEventID($event->getID())->setEpochRange($epoch_min, $epoch_max)->setIsAllDay($event->getIsAllDay())->setIcon($event->getIcon())->setViewerIsInvited($viewer_is_invited)->setName($event->getName())->setDatetimeSummary($event->renderEventDate($viewer, true))->setURI($event->getURI());
$event_views[] = $event_view;
}
$event_views = msort($event_views, 'getEpochStart');
$day_view = id(new PHUICalendarWeekView())->setViewer($viewer)->setView('week')->setEvents($event_views)->setWeekLength(3)->render();
$header = id(new PHUIHeaderView())->setHeader(pht('Calendar'))->setHref(urisprintf('/calendar/?invited=%s#R', $user->getUsername()));
$box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($day_view)->addClass('calendar-profile-box')->setBackground(PHUIObjectBoxView::GREY);
return $box;
}
示例2: buildCalendarDayView
private function buildCalendarDayView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorCalendarApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$midnight = PhabricatorTime::getTodayMidnightDateTime($viewer);
$week_end = clone $midnight;
$week_end = $week_end->modify('+3 days');
$range_start = $midnight->format('U');
$range_end = $week_end->format('U');
$query = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withDateRange($range_start, $range_end)->withInvitedPHIDs(array($user->getPHID()))->withIsCancelled(false);
$statuses = $query->execute();
$phids = mpull($statuses, 'getUserPHID');
$events = array();
foreach ($statuses as $status) {
$viewer_is_invited = $status->getIsUserInvited($user->getPHID());
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $status, PhabricatorPolicyCapability::CAN_EDIT);
$event = id(new AphrontCalendarEventView())->setCanEdit($can_edit)->setEventID($status->getID())->setEpochRange($status->getDateFrom(), $status->getDateTo())->setIsAllDay($status->getIsAllDay())->setIcon($status->getIcon())->setViewerIsInvited($viewer_is_invited)->setName($status->getName())->setURI($status->getURI());
$events[] = $event;
}
$events = msort($events, 'getEpochStart');
$day_view = id(new PHUICalendarWeekView())->setViewer($viewer)->setView('week')->setEvents($events)->setWeekLength(3)->render();
$header = id(new PHUIHeaderView())->setHeader(pht('Calendar'))->setHref(urisprintf('/calendar/?invitedPHIDs=%s#R', $user->getPHID()));
$box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($day_view)->setBackground(PHUIObjectBoxView::GREY);
return $box;
}
示例3: getSafeDate
private function getSafeDate($value)
{
$viewer = $this->requireViewer();
if ($value) {
// ideally this would be consistent and always pass in the same type
if ($value instanceof AphrontFormDateControlValue) {
return $value;
} else {
$value = AphrontFormDateControlValue::newFromWild($viewer, $value);
}
} else {
$value = AphrontFormDateControlValue::newFromEpoch($viewer, PhabricatorTime::getTodayMidnightDateTime($viewer)->format('U'));
$value->setEnabled(false);
}
$value->setOptional(true);
return $value;
}
示例4: getDefaultDateTime
private function getDefaultDateTime()
{
return PhabricatorTime::getTodayMidnightDateTime($this->getViewer());
}
示例5: getWeekOfBoxes
private function getWeekOfBoxes()
{
$sidebar_day_boxes = array();
$display_start_day = $this->getDateTime();
$display_end_day = id(clone $display_start_day)->modify('+6 day');
$box_start_time = clone $display_start_day;
$today_time = PhabricatorTime::getTodayMidnightDateTime($this->user);
$tomorrow_time = clone $today_time;
$tomorrow_time->modify('+1 day');
while ($box_start_time <= $display_end_day) {
if ($box_start_time == $today_time) {
$title = pht('Today');
} else {
if ($box_start_time == $tomorrow_time) {
$title = pht('Tomorrow');
} else {
$title = $box_start_time->format('l');
}
}
$sidebar_day_boxes[] = array('title' => $title, 'start' => clone $box_start_time);
$box_start_time->modify('+1 day');
}
return $sidebar_day_boxes;
}