public function setNthWeekday($weekday, $nth = 1)
{
if ($weekday < self::DATE_SUNDAY || $weekday > self::DATE_SATURDAY) {
return;
}
if ($nth >= 0) {
$this->_mday = 1;
$first = $this->dayOfWeek();
$this->_mday = $weekday - $first + 1;
if ($weekday < $first) {
$this->_mday += 7;
}
$diff = 7 * $nth - 7;
$this->_mday += $diff;
$this->_correct(self::MASK_DAY, false);
} else {
$this->_mday = Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
$last = $this->dayOfWeek();
$this->_mday -= $last - $weekday;
if ($last < $weekday) {
$this->_mday -= 7;
}
$diff = -7 * $nth - 7;
$this->_mday -= $diff;
$this->_correct(self::MASK_DAY, true);
$this->_formatCache = array();
}
}