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

static int icaltimezone_find_nearby_change ( icaltimezone *  zone,
icaltimezonechange *  change 
) [static]

Returns the index of a timezone change which is close to the time given in change.

Definition at line 1064 of file icaltimezone.c.

References icaltimezone_compare_change_fn().

Referenced by icaltimezone_get_utc_offset(), and icaltimezone_get_utc_offset_of_utc_time().

{
    icaltimezonechange *zone_change;
    int lower, upper, middle, cmp;
                               
    /* Do a simple binary search. */
    lower = middle = 0;
    upper = zone->changes->num_elements;

    while (lower < upper) {
      middle = (lower + upper) / 2;
      zone_change = icalarray_element_at (zone->changes, middle);
      cmp = icaltimezone_compare_change_fn (change, zone_change);
      if (cmp == 0)
          break;
      else if (cmp < 0)
          upper = middle;
      else
          lower = middle + 1;
    }

    return middle;
}


Generated by  Doxygen 1.6.0   Back to index