本文整理汇总了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);
}
示例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;
}