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

struct icaltimetype icalrecur_iterator_next ( icalrecur_iterator  )  [read]

Get the next occurrence from an iterator

Definition at line 2221 of file icalrecur.c.

Referenced by icalrecur_expand_recurrence().

{
    int valid = 1;
    
    if( (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) ||
       (!icaltime_is_null_time(impl->rule.until) && 
      icaltime_compare(impl->last,impl->rule.until) > 0)) {
      return icaltime_null_time();
    }

    if(impl->occurrence_no == 0 
       &&  icaltime_compare(impl->last,impl->dtstart) >= 0){

      impl->occurrence_no++;
      return impl->last;
    }

    do {
        valid = 1;
      switch(impl->rule.freq){
          
          case ICAL_SECONDLY_RECURRENCE: {
            next_second(impl);
            break;
          }
          case ICAL_MINUTELY_RECURRENCE: {
            next_minute(impl);
            break;
          }
          case ICAL_HOURLY_RECURRENCE: {
            next_hour(impl);
            break;
          }
          case ICAL_DAILY_RECURRENCE: {
            next_day(impl);
            break;
          }
          case ICAL_WEEKLY_RECURRENCE: {
            next_week(impl);
            break;
          }
          case ICAL_MONTHLY_RECURRENCE: {
            valid = next_month(impl);
            break;
          }
          case ICAL_YEARLY_RECURRENCE:{
            next_year(impl);
            break;
          }
          default:{
            icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
                return icaltime_null_time();
          }
      }    
      
      if(impl->last.year >= 2038 ){
          /* HACK */
          return icaltime_null_time();
      }
      
    } while(!check_contracting_rules(impl) 
          || icaltime_compare(impl->last,impl->dtstart) < 0
            || valid == 0);
    
    
/* Ignore null times and times that are after the until time */
    if( !icaltime_is_null_time(impl->rule.until) && 
      icaltime_compare(impl->last,impl->rule.until) > 0 ) {
      return icaltime_null_time();
    }

    impl->occurrence_no++;

    return impl->last;
}


Generated by  Doxygen 1.6.0   Back to index