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

icaltimezone* icaltimezone_get_builtin_timezone ( const char *  location  ) 

Returns a single builtin timezone, given its Olson city name.

Definition at line 1363 of file icaltimezone.c.

References builtin_timezones, icaltimezone_get_location(), icaltimezone_init_builtin_timezones(), and utc_timezone.

Referenced by icaltimezone_get_builtin_timezone_from_tzid().

{
    icaltimezone *zone;
    int lower;
    const char *zone_location;

    if (!location || !location[0])
      return NULL;

    if (!builtin_timezones)
      icaltimezone_init_builtin_timezones ();

    if (!strcmp (location, "UTC"))
      return &utc_timezone;
    
#if 0
    /* Do a simple binary search. */
    lower = middle = 0;
    upper = builtin_timezones->num_elements;

    while (lower < upper) {
      middle = (lower + upper) / 2;
      zone = icalarray_element_at (builtin_timezones, middle);
      zone_location = icaltimezone_get_location (zone);
      cmp = strcmp (location, zone_location);
      if (cmp == 0)
          return zone;
      else if (cmp < 0)
          upper = middle;
      else
          lower = middle + 1;
    }
#endif

    /* The zones from the system are not stored in alphabetical order,
       so we just do a sequential search */
    for (lower = 0; lower < builtin_timezones->num_elements; lower++) {
      zone = icalarray_element_at (builtin_timezones, lower);
      zone_location = icaltimezone_get_location (zone);
      if (strcmp (location, zone_location) == 0)
            return zone;
    }

    return NULL;
}


Generated by  Doxygen 1.6.0   Back to index