Logo Search packages:      
Sourcecode: davical version File versions  Download package

& iCalDate::MonthDays ( dow_first,
days_in_month,
dayspec 
)

Given a MonthDays string like "1MO", "-2WE" return an integer day of the month.

Parameters:
string$dow_firstThe day of week of the first of the month.
string$days_in_monthThe number of days in the month.
string$dayspecThe specification for a month day (or days) which we parse.
Returns:
array An array of the day numbers for the month which meet the rule.

Definition at line 502 of file RRule.php.

Referenced by GetMonthByDay().

                                                            {
    global $ical_weekdays;
    dbg_error_log( "RRule", "MonthDays: Getting days for '%s'. %d days starting on a %d", $dayspec, $days_in_month, $dow_first );
    $set = array();
    preg_match( '/([0-9-]*)(MO|TU|WE|TH|FR|SA|SU)/', $dayspec, $matches);
    $numeric = intval($matches[1]);
    $dow = $ical_weekdays[$matches[2]];

    $first_matching_day = 1 + ($dow - $dow_first);
    while ( $first_matching_day < 1 ) $first_matching_day += 7;

    dbg_error_log( "RRule", " MonthDays: Looking at %d for first match on (%s/%s), %d for numeric", $first_matching_day, $matches[1], $matches[2], $numeric );

    while( $first_matching_day <= $days_in_month ) {
      $set[] = $first_matching_day;
      $first_matching_day += 7;
    }

    if ( $numeric != 0 ) {
      if ( $numeric < 0 ) {
        $numeric += count($set);
      }
      else {
        $numeric--;
      }
      $answer = $set[$numeric];
      $set = array( $answer => $answer );
    }
    else {
      $answers = $set;
      $set = array();
      foreach( $answers AS $k => $v ) {
        $set[$v] = $v;
      }
    }

//    dbg_log_array( "RRule", 'MonthDays', $set, false );

    return $set;
  }

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index