iphone dev how to retrieve past to future google calender events
<p>Hi programmers i want to retrieve google calender events. my requirement is that i want to retrieve evnts of 6 months before current date and 6 months after current date, means if today is 2nd november 2011, then i want to retrieve events of 6 months before(past) and after(future) of 2nd november, here is how i am doing it, using gdata api,</p>

<pre><code>- (void)calendarsTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedCalendar *)feed error:(NSError *)error{
  if( !error ){
    int count = [[feed entries] count];
    if (count!=0) {

     my_selected_calendar=[[feed entries] objectAtIndex:0];
    }
    for( int i=0; i&lt;count; i++ ){
      GDataEntryCalendar *calendar = [[feed entries] objectAtIndex:i];
my_selected_calendar=[[feed entries] objectAtIndex:0];
      // Create a dictionary containing the calendar and the ticket to fetch its events.
      NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
      [data addObject:dictionary];

      [dictionary setObject:calendar forKey:KEY_CALENDAR];
      [dictionary setObject:[[NSMutableArray alloc] init] forKey:KEY_EVENTS];

      if( [calendar ACLLink] )  // We can determine whether the calendar is under user's control by the existence of its edit link.
        [dictionary setObject:KEY_EDITABLE forKey:KEY_EDITABLE];

      NSURL *feedURL = [[calendar alternateLink] URL];
      if( feedURL ){
        GDataQueryCalendar* query = [GDataQueryCalendar calendarQueryWithFeedURL:feedURL];

        // Currently, the app just shows calendar entries from 15 days ago to 31 days from now.
        // Ideally, we would instead use similar controls found in Google Calendar web interface, or even iCal's UI.
        **NSDate *minDate1 = [NSDate date];  // From right now...
        NSDate *minDate = [minDate1 dateByAddingTimeInterval:-60*60*24*182]; 
          NSLog(@"%@",minDate);


        NSDate *maxDate = [minDate1 dateByAddingTimeInterval:60*60*24*365];  // ...to 90 days from now.
           // NSLog(@"%@",maxDate);
        [query setMinimumStartTime:[GDataDateTime dateTimeWithDate:minDate timeZone:[NSTimeZone systemTimeZone]]];
          //[query 
        [query setMaximumStartTime:[GDataDateTime dateTimeWithDate:maxDate timeZone:[NSTimeZone systemTimeZone]]];**
        [query setOrderBy:@"starttime"];  // http://code.google.com/apis/calendar/docs/2.0/reference.html#Parameters
        [query setIsAscendingOrder:YES];
        [query setShouldExpandRecurrentEvents:YES];
          daily_trackAppDelegate *controller =(daily_trackAppDelegate *) [[UIApplication sharedApplication] delegate];

          [controller.googlearray removeAllObjects];

        GDataServiceTicket *ticket = [googleCalendarService fetchFeedWithQuery:query delegate:self didFinishSelector:@selector( eventsTicket:finishedWithEntries:error: )];
        // I add the service ticket to the dictionary to make it easy to find which calendar each reply belongs to.
        [dictionary setObject:ticket forKey:KEY_TICKET];
      }
    }
  }else
    [self handleError:error];

  [self.tableView reloadData];
}
</code></pre>

<p>but i am not succeeding in it, it is duplicating the event values n also it is retrieving events of almost 25 days in future from current date, i am stuck here plz. guide me. thanx n regards Saad.</p>
