*** evolution-data-server-1.6.0/calendar/libical/src/libical/icaltimezone.c.orig	2006-03-22 09:59:15.000000000 +0100
--- evolution-data-server-1.6.0/calendar/libical/src/libical/icaltimezone.c	2006-03-22 16:31:42.673905745 +0100
***************
*** 1358,1363 ****
--- 1358,1486 ----
      return NULL;
  }
  
+ /**
+  * Given a non-standard TZID try to guess the corresponding builtin
+  * timezone.
+  *
+  * Currently works for TZIDs as generated by Outlook 2003. Examples:
+  * - "(GMT) Greenwich Mean Time/Dublin/Edinburgh/London"
+  * - "(GMT-05.00) Eastern Time (US & Canada)"
+  * The mapping is based on the GMT offset instead of the location
+  * after it because it was easier to provide full coverage of
+  * all offsets. Differences between different locations
+  * with the same offset are lost that way, though.
+  *
+  * Also supports plain "GMT +0100 (Standard) / GMT +0200 (Daylight)"
+  * by assuming that the first part can be used to match with a location.
+  *
+  * Without this additional code those timezones were silently
+  * ignored, see http://bugzilla.gnome.org/show_bug.cgi?id=332911
+  */
+ icaltimezone*
+ icaltimezone_guess_builtin_timezone_from_tzid (const char *tzid)
+ {
+     static const char *outlookgmtprefix = "(GMT";
+     static const char *simplegmtprefix = "GMT";
+     int gmtoffset = 24 * 60; /* offsets from GMT in minutes */
+     static struct {
+ 	int gmtoffset;             /**< offset as specified by Outlook */
+ 	const char *location;      /**< a location as known by Evolution which
+ 				      happens to be at that offset, might be the
+ 				      original Outlook location if no match was found
+ 				      (International_Date_Line_West, Mid-Atlantic, Nuku'alofa)
+ 				   */
+     } gmtoffset2location[] = {
+ 	/* comments indicate the string used in Outlook */
+ 	{ -12 * 60, NULL }, /* International Date Line West */
+ 	{ -11 * 60, "Pacific/Midway" }, /* Midway Island, Samoa */
+ 	{ -10 * 60, "Pacific/Honolulu" }, /* Hawaii */
+ 	{  -9 * 60, "America/Anchorage" }, /* Alaska */
+ 	{  -8 * 60, "America/Tijuana" }, /* Pacific Time (US & Canada); Tijuana */
+ 	{  -7 * 60, "America/Phoenix" }, /* Arizona and others */
+ 	{  -6 * 60, "America/Chicago" }, /* Central America aka Central Time */
+ 	{  -5 * 60, "America/Montreal" }, /* Eastern Time (US & Canada) */
+ 	{  -4 * 60, "America/Halifax" }, /* Atlantic Time (Canada) */
+ 	{  -3 * 60 - 30, "America/St_Johns" }, /* Newfoundland */
+ 	{  -3 * 60, "America/Buenos_Aires" }, /* Buenos Aires, Georgetown */
+ 	{  -2 * 60, NULL }, /* Mid-Atlantic */
+ 	{  -1 * 60, "Atlantic/Azores" }, /* Azores */
+ 	{   0 * 60, "Europe/London" }, /* Greenwich Mean Time: Dublin, Edinburgh, ... */
+ 	{   1 * 60, "Europe/Berlin" }, /* Amsterdam, Berlin, ... and others */
+ 	{   2 * 60, "Europe/Athens" }, /* Athens and others */
+ 	{   3 * 60, "Europe/Moscow" }, /* Moscow, ... */
+ 	{   3 * 60 + 30, "Asia/Tehran" }, /* Tehran */
+ 	{   4 * 60, "Asia/Muscat" }, /* Abu Dhabi, Muscat */
+ 	{   4 * 60 + 30, "Asia/Kabul" }, /* Kabul */
+ 	{   5 * 60, "Asia/Yekaterinburg" }, /* Ekaterinburg and Islamabad, ... */
+ 	{   5 * 60 + 30, "Asia/Calcutta" }, /* Chennai, Kolkata, Mumbai, New Delhi */
+ 	{   5 * 60 + 45, "Asia/Katmandu" }, /* Kathmandu */
+ 	{   6 * 60, "Asia/Novosibirsk" }, /* Almaty, Novosibirsk and Astana, Dhaka */
+ 	{   6 * 60 + 30, "Asia/Rangoon" }, /* Rangoon */
+ 	{   7 * 60, "Asia/Bangkok" }, /* Bangkog, Hanoi, Jakarta and Krasnoyarsk */
+ 	{   8 * 60, "Asia/Hong_Kong" }, /* Bejing, Chongquing, Hong Kong, Urumqi and others */
+ 	{   9 * 60, "Asia/Tokyo" }, /* Osaka, Sapporo, Tokyo and others */
+ 	{   9 * 60 + 30, "Australia/Adelaide" }, /* Adelaide and others */
+ 	{   10 * 60, "Australia/Brisbane" }, /* Brisbane and others */
+ 	{   11 * 60, "Pacific/Ponape" }, /* Magadan, Solomon Is., New Caledonia */
+ 	{   12 * 60, "Pacific/Auckland" }, /* Auckland, Wellington and others */
+ 	{   13 * 60, NULL } /* Nuku'alofa */
+     };
+     int index;
+     icaltimezone * zone = NULL;
+ 
+     if (!strncmp (tzid, outlookgmtprefix, strlen (outlookgmtprefix))) {
+ 	int hour = 0, min = 0;
+ 
+ 	/* intentionally ignore parsing errors, proceed with hour/min = 0 then */
+ 	sscanf (tzid+strlen(outlookgmtprefix), "%d.%d", &hour, &min);
+ 	gmtoffset = hour * 60 + (hour < 0 ? -1 : 1 ) * min;
+     } else if (!strncmp (tzid, simplegmtprefix, strlen (simplegmtprefix))) {
+ 	int hour = 0, min = 0;
+ 	int sign = 1;
+ 	const char *time = tzid + strlen (simplegmtprefix);
+ 
+ 	while (isspace (*time)) {
+ 	    time++;
+ 	}
+ 	switch (*time) {
+ 	case '-':
+ 	    sign = -1;
+ 	    time++;
+ 	    break;
+ 	case '+':
+ 	    time++;
+ 	    break;
+ 	}
+ 	/* intentionally ignore parsing errors, proceed with hour/min = 0 then */
+ 	sscanf (time, "%2d%d", &hour, &min);
+ 
+ 	gmtoffset = sign * (hour * 60 + min);
+     }
+ 
+     for (index = 0;
+ 	 index < sizeof(gmtoffset2location)/sizeof(gmtoffset2location[0]);
+ 	 index++) {
+ 	if (gmtoffset2location[index].gmtoffset == gmtoffset) {
+ 	    if (gmtoffset2location[index].location) {
+ 		zone = icaltimezone_get_builtin_timezone (gmtoffset2location[index].location);
+ 		break;
+ 	    } else {
+ 		/* no corresponding Evolution location */
+ 		break;
+ 	    }
+ 	}
+     }
+ 
+     /* too bad, nothing found - this should not be ignore silently! */
+     if (!zone) {
+ 	char buffer[256];
+ 	sprintf (buffer, "guessing timezone failed for: %.200s", tzid);
+ 	icalerror_warn (buffer);
+     }
+ 
+     return zone;
+ }
+ 
  
  /** Returns a single builtin timezone, given its TZID. */
  icaltimezone*
***************
*** 1371,1378 ****
  	return NULL;
  
      /* Check that the TZID starts with our unique prefix. */
!     if (strncmp (tzid, TZID_PREFIX, TZID_PREFIX_LEN))
! 	return NULL;
  
      /* Get the location, which is after the 3rd '/' character. */
      p = tzid;
--- 1494,1503 ----
  	return NULL;
  
      /* Check that the TZID starts with our unique prefix. */
!     if (strncmp (tzid, TZID_PREFIX, TZID_PREFIX_LEN)) {
! 	/* don't give up so easily, at least guess */
! 	return icaltimezone_guess_builtin_timezone_from_tzid (tzid);
!     }
  
      /* Get the location, which is after the 3rd '/' character. */
      p = tzid;
