[california] Handle libical's tzid prefix
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Handle libical's tzid prefix
- Date: Tue, 25 Mar 2014 23:09:03 +0000 (UTC)
commit 822c1d0c668b79643e44395014201dacc4a001fb
Author: Jim Nelson <jim yorba org>
Date: Tue Mar 25 16:08:06 2014 -0700
Handle libical's tzid prefix
Some users of libical generate iCal components with its tzid prefix.
This catches those situations and converts the prefixed tzid into
a proper Olson zone.
src/component/component-date-time.vala | 12 ++++++++++--
vapi/libical.vapi | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/component/component-date-time.vala b/src/component/component-date-time.vala
index 56fcb63..3795a69 100644
--- a/src/component/component-date-time.vala
+++ b/src/component/component-date-time.vala
@@ -100,8 +100,16 @@ public class DateTime : BaseObject, Gee.Hashable<DateTime>, Gee.Comparable<DateT
throw new ComponentError.INVALID("DATE-TIME for %s is invalid", ical_prop_kind.to_string());
unowned iCal.icalparameter? param = prop.get_first_parameter(iCal.icalparameter_kind.TZID_PARAMETER);
- if (param != null)
- zone = new Calendar.OlsonZone(param.get_tzid());
+ if (param != null) {
+ // first, see if libical can convert this into builtin timezone; this indicates the
+ // component was (probably) created with another instance of libical that has added its
+ // timezone "prefix" to the tzid; otherwise, treat tzid as a straight-up Olson zone
+ unowned iCal.icaltimezone? tz =
iCal.icaltimezone.get_builtin_timezone_from_tzid(param.get_tzid());
+ if (tz != null)
+ zone = new Calendar.OlsonZone(tz.get_location());
+ else
+ zone = new Calendar.OlsonZone(param.get_tzid());
+ }
kind = ical_prop_kind;
}
diff --git a/vapi/libical.vapi b/vapi/libical.vapi
index fb5e7df..7950841 100644
--- a/vapi/libical.vapi
+++ b/vapi/libical.vapi
@@ -1402,7 +1402,7 @@ namespace iCal {
[CCode (cname = "icaltimezone_get_builtin_timezone_from_offset")]
public static unowned iCal.icaltimezone get_builtin_timezone_from_offset (int offset, string
tzname);
[CCode (cname = "icaltimezone_get_builtin_timezone_from_tzid")]
- public static unowned iCal.icaltimezone get_builtin_timezone_from_tzid (string tzid);
+ public static unowned iCal.icaltimezone? get_builtin_timezone_from_tzid (string tzid);
[CCode (cname = "icaltimezone_get_builtin_timezones")]
public static unowned iCal.icalarray get_builtin_timezones ();
[CCode (cname = "icaltimezone_get_component")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]