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


PHP Horde_Date::sub方法代码示例

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


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

示例1: testDateMath

 public function testDateMath()
 {
     $d = new Horde_Date('2008-01-01 00:00:00');
     $this->assertEquals('2007-12-31 00:00:00', (string) $d->sub(array('day' => 1)));
     $this->assertEquals('2009-01-01 00:00:00', (string) $d->add(array('year' => 1)));
     $this->assertEquals('2008-01-01 04:00:00', (string) $d->add(14400));
     $span = new Horde_Date_Span('2006-01-01 00:00:00', '2006-08-16 00:00:00');
     $this->assertEquals('2006-04-24 11:30:00', (string) $span->begin->add($span->width() / 2));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:9,代码来源:DateTest.php

示例2: _isNthOcurrenceOfWeekdayInMonth

 /**
  * Test if the weekday of the given timestamp is the nth occurence of this
  * weekday within its month, where '5' indicates the last occurrence even if
  * there is less than five occurrences.
  *
  * @param integer $timestamp  The timestamp to check.
  * @param integer $occurence  1 to 5, where 5 indicates the final occurrence
  *                            during the month if that day of the week does
  *                            not occur 5 times
  * @return boolean
  */
 protected static function _isNthOcurrenceOfWeekdayInMonth($timestamp, $occurence)
 {
     $original = new Horde_Date($timestamp);
     $original->setTimezone('UTC');
     if ($occurence == 5) {
         $modified = $original->add(array('mday' => 7));
         return $modified->month > $original->month;
     } else {
         $modified = $original->sub(array('mday' => 7 * $occurence));
         $modified2 = $original->sub(array('mday' => 7 * ($occurence - 1)));
         return $modified->month < $original->month && $modified2->month == $original->month;
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:24,代码来源:Timezone.php

示例3: sub

 /**
  * Subtract a number of seconds from this span, returning the new span.
  */
 public function sub($factor)
 {
     return new Horde_Date_Span($this->begin->sub($factor), $this->end->sub($factor));
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:7,代码来源:Span.php

示例4: _vEventException

 /**
  * Generate the HTML for a vEvent.
  */
 protected function _vEventException($vevent, $id, $method = 'PUBLISH')
 {
     global $prefs, $registry;
     $attendees = null;
     $options = array();
     try {
         if (($attendees = $vevent->getAttribute('ATTENDEE')) && !is_array($attendees)) {
             $attendees = array($attendees);
         }
     } catch (Horde_Icalendar_Exception $e) {
     }
     $view = $this->_getViewOb();
     try {
         $start = $vevent->getAttribute('DTSTART');
         $view->start = is_array($start) ? strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $start['month'], $start['mday'], $start['year'])) : strftime($prefs->getValue('date_format'), $start) . ' ' . date($prefs->getValue('twentyFour') ? ' G:i' : ' g:i a', $start);
     } catch (Horde_Icalendar_Exception $e) {
         $start = null;
     }
     try {
         $end = $vevent->getAttribute('DTEND');
         // Check for exceptions that are over and done with.
         $d = new Horde_Date($end);
         if ($d->timestamp() < time()) {
             return false;
         }
         $view->end = is_array($end) ? strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $end['month'], $end['mday'], $end['year'])) : strftime($prefs->getValue('date_format'), $end) . ' ' . date($prefs->getValue('twentyFour') ? ' G:i' : ' g:i a', $end);
     } catch (Horde_Icalendar_Exception $e) {
         $end = null;
     }
     try {
         $summary = $vevent->getAttribute('SUMMARY');
         $view->summary = $summary;
     } catch (Horde_Icalendar_Exception $e) {
         $summary = _("Unknown Meeting");
         $view->summary_error = _("None");
     }
     try {
         $view->desc2 = $vevent->getAttribute('DESCRIPTION');
     } catch (Horde_Icalendar_Exception $e) {
     }
     try {
         $view->loc = $vevent->getAttribute('LOCATION');
     } catch (Horde_Icalendar_Exception $e) {
     }
     if (!empty($attendees)) {
         $view->attendees = $this->_parseAttendees($vevent, $attendees);
     }
     if (!is_null($start) && !is_null($end) && in_array($method, array('PUBLISH', 'REQUEST', 'ADD')) && $registry->hasMethod('calendar/getFbCalendars') && $registry->hasMethod('calendar/listEvents')) {
         try {
             $calendars = $registry->call('calendar/getFbCalendars');
             $vevent_start = new Horde_Date($start);
             $vevent_end = new Horde_Date($end);
             // Check if it's an all-day event.
             if (is_array($start)) {
                 $vevent_allDay = true;
                 $vevent_end = $vevent_end->sub(1);
             } else {
                 $vevent_allDay = false;
                 $time_span_start = $vevent_start->sub($prefs->getValue('conflict_interval') * 60);
                 $time_span_end = $vevent_end->add($prefs->getValue('conflict_interval') * 60);
             }
             $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false));
             // TODO: Check if there are too many events to show.
             $conflicts = array();
             foreach ($events as $calendar) {
                 foreach ($calendar as $event) {
                     // TODO: WTF? Why are we using Kronolith constants
                     // here?
                     if (in_array($event->status, array(Kronolith::STATUS_CANCELLED, Kronolith::STATUS_FREE))) {
                         continue;
                     }
                     if ($vevent_allDay || $event->isAllDay()) {
                         $type = 'collision';
                     } elseif ($event->end->compareDateTime($time_span_start) <= -1 || $event->start->compareDateTime($time_span_end) >= 1) {
                         continue;
                     } elseif ($event->end->compareDateTime($vevent_start) <= -1 || $event->start->compareDateTime($vevent_end) >= 1) {
                         $type = 'nearcollision';
                     } else {
                         $type = 'collision';
                     }
                     $conflicts[] = array('collision' => $type == 'collision', 'range' => $event->getTimeRange(), 'title' => $event->getTitle());
                 }
             }
             if (!empty($conflicts)) {
                 $view->conflicts = $conflicts;
             }
         } catch (Horde_Exception $e) {
         }
     }
     if (!empty($options)) {
         reset($options);
         $view->options = $options;
         $view->options_id = $id;
     }
     return $view->render('action');
 }
开发者ID:Gomez,项目名称:horde,代码行数:99,代码来源:Itip.php


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