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


PHP Horde_Date::setNthWeekday方法代碼示例

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


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

示例1: testSetNthWeekday

 public function testSetNthWeekday()
 {
     $date = new Horde_Date('2004-10-01');
     $date->setNthWeekday(Horde_Date::DATE_SATURDAY);
     $this->assertEquals(2, $date->mday);
     $date->setNthWeekday(Horde_Date::DATE_SATURDAY, 2);
     $this->assertEquals(9, $date->mday);
     $date = new Horde_Date('2007-04-01');
     $date->setNthWeekday(Horde_Date::DATE_THURSDAY);
     $this->assertEquals(5, $date->mday);
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:11,代碼來源:DateTest.php

示例2: fromKolab


//.........這裏部分代碼省略.........
                     $update_month = true;
                     $update_daynumber = true;
                     break;
                 case 'yearday':
                     if (!isset($hash['daynumber'])) {
                         $this->setRecurType(self::RECUR_NONE);
                         return false;
                     }
                     $this->setRecurType(self::RECUR_YEARLY_DAY);
                     // Start counting days in January.
                     $hash['month'] = 'january';
                     $update_month = true;
                     $update_daynumber = true;
                     break;
                 case 'weekday':
                     if (!isset($hash['daynumber'])) {
                         $this->setRecurType(self::RECUR_NONE);
                         return false;
                     }
                     $this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
                     $nth_weekday = (int) $hash['daynumber'];
                     $hash['daynumber'] = 1;
                     $parse_day = true;
                     $update_month = true;
                     $update_daynumber = true;
                     $update_weekday = true;
                     break;
             }
     }
     if (isset($hash['range-type']) && isset($hash['range'])) {
         switch ($hash['range-type']) {
             case 'number':
                 $this->setRecurCount((int) $hash['range']);
                 break;
             case 'date':
                 $recur_end = new Horde_Date($hash['range']);
                 $recur_end->hour = 23;
                 $recur_end->min = 59;
                 $recur_end->sec = 59;
                 $this->setRecurEnd($recur_end);
                 break;
         }
     }
     // Need to parse <day>?
     $last_found_day = -1;
     if ($parse_day) {
         if (!isset($hash['day'])) {
             $this->setRecurType(self::RECUR_NONE);
             return false;
         }
         $mask = 0;
         $bits = array('monday' => Horde_Date::MASK_MONDAY, 'tuesday' => Horde_Date::MASK_TUESDAY, 'wednesday' => Horde_Date::MASK_WEDNESDAY, 'thursday' => Horde_Date::MASK_THURSDAY, 'friday' => Horde_Date::MASK_FRIDAY, 'saturday' => Horde_Date::MASK_SATURDAY, 'sunday' => Horde_Date::MASK_SUNDAY);
         $days = array('monday' => Horde_Date::DATE_MONDAY, 'tuesday' => Horde_Date::DATE_TUESDAY, 'wednesday' => Horde_Date::DATE_WEDNESDAY, 'thursday' => Horde_Date::DATE_THURSDAY, 'friday' => Horde_Date::DATE_FRIDAY, 'saturday' => Horde_Date::DATE_SATURDAY, 'sunday' => Horde_Date::DATE_SUNDAY);
         foreach ($hash['day'] as $day) {
             // Validity check.
             if (empty($day) || !isset($bits[$day])) {
                 continue;
             }
             $mask |= $bits[$day];
             $last_found_day = $days[$day];
         }
         if ($set_daymask) {
             $this->setRecurOnDay($mask);
         }
     }
     if ($update_month || $update_daynumber || $update_weekday) {
         if ($update_month) {
             $month2number = array('january' => 1, 'february' => 2, 'march' => 3, 'april' => 4, 'may' => 5, 'june' => 6, 'july' => 7, 'august' => 8, 'september' => 9, 'october' => 10, 'november' => 11, 'december' => 12);
             if (isset($month2number[$hash['month']])) {
                 $this->start->month = $month2number[$hash['month']];
             }
         }
         if ($update_daynumber) {
             if (!isset($hash['daynumber'])) {
                 $this->setRecurType(self::RECUR_NONE);
                 return false;
             }
             $this->start->mday = $hash['daynumber'];
         }
         if ($update_weekday) {
             $this->start->setNthWeekday($last_found_day, $nth_weekday);
         }
     }
     // Exceptions.
     if (isset($hash['exclusion'])) {
         foreach ($hash['exclusion'] as $exception) {
             if ($exception instanceof DateTime) {
                 $this->exceptions[] = $exception->format('Ymd');
             }
         }
     }
     if (isset($hash['complete'])) {
         foreach ($hash['complete'] as $completion) {
             if ($exception instanceof DateTime) {
                 $this->completions[] = $completion->format('Ymd');
             }
         }
     }
     return true;
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:101,代碼來源:Recurrence.php


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