diff options
author | Milan Crha <mcrha@redhat.com> | 2019-03-22 08:51:59 +0100 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2019-03-22 08:51:59 +0100 |
commit | 7e5df164b60ddd0652529725e95a948fb7a0b0d5 (patch) | |
tree | 6d4ae44ec0d1a81039cfa23de63ed4a2a7e7dda9 /src | |
parent | 02613a2a2b4182a76f964355ef652b3d0d24d956 (diff) | |
download | libical-git-7e5df164b60ddd0652529725e95a948fb7a0b0d5.tar.gz |
[libical-glib] Introduce i_cal_time_convert_to_zone_inplace()
It modifies the inner native object, with no need to allocate a new ICalObject.
Diffstat (limited to 'src')
-rw-r--r-- | src/libical-glib/api/i-cal-time.xml | 19 | ||||
-rwxr-xr-x | src/test/libical-glib/timezone.py | 15 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/libical-glib/api/i-cal-time.xml b/src/libical-glib/api/i-cal-time.xml index 35448066..7ee5ac62 100644 --- a/src/libical-glib/api/i-cal-time.xml +++ b/src/libical-glib/api/i-cal-time.xml @@ -155,10 +155,25 @@ <comment xml:space="preserve">Normalize the icaltime, so that all fields are within the normal range.</comment> </method> <method name="i_cal_time_convert_to_zone" corresponds="icaltime_convert_to_zone" since="1.0"> - <parameter type="ICalTimetype *" name="t" annotation="in, transfer none" comment="The #ICalTimetype to be normalized"/> + <parameter type="ICalTimetype *" name="tt" annotation="in, transfer none" comment="The #ICalTimetype to be converted"/> <parameter type="ICalTimezone *" name="zone" annotation="transfer none, nullable" comment="The target timezone"/> <returns type="ICalTimetype *" annotation="transfer full" comment="The converted #ICalTimetype" /> - <comment xml:space="preserve">Convert tt, of timezone tzid, into a utc time. Does nothing if the time is already UTC.</comment> + <comment xml:space="preserve">Convert @tt to @zone and return new %ICalTimetype object.</comment> + </method> + <method name="i_cal_time_convert_to_zone_inplace" corresponds="CUSTOM" since="3.0.5"> + <parameter type="ICalTimetype *" name="tt" comment="The #ICalTimetype to be converted"/> + <parameter type="ICalTimezone *" name="zone" annotation="transfer none, nullable" comment="The target timezone"/> + <comment xml:space="preserve">Convert @tt to @zone and store the result into @tt.</comment> + <custom xml:space="preserve"> icaltimetype *itt; + + g_return_if_fail (I_CAL_IS_TIMETYPE (tt)); + if(zone) + g_return_if_fail (I_CAL_IS_TIMEZONE (zone)); + + itt = i_cal_object_get_native (I_CAL_OBJECT (tt)); + g_return_if_fail (itt != NULL); + + *itt = icaltime_convert_to_zone (*itt, ((zone)?((icaltimezone *)i_cal_object_get_native (I_CAL_OBJECT (zone))):NULL));</custom> </method> <method name="i_cal_time_days_in_month" corresponds="icaltime_days_in_month" since="1.0"> <parameter type="const gint" name="month" comment="The target month"/> diff --git a/src/test/libical-glib/timezone.py b/src/test/libical-glib/timezone.py index 00f77027..829de026 100755 --- a/src/test/libical-glib/timezone.py +++ b/src/test/libical-glib/timezone.py @@ -72,6 +72,21 @@ assert ICalGLib.Timetype.get_zone(time) == utc; ICalGLib.Timetype.set_zone(time, la); assert ICalGLib.Timetype.get_zone(time) == la; +timeclone = time.new_clone() +assert time != timeclone +time = ICalGLib.time_convert_to_zone(time, chicago) +ICalGLib.time_convert_to_zone_inplace(timeclone, chicago) +assert time.get_year() == timeclone.get_year(); +assert time.get_month() == timeclone.get_month(); +assert time.get_day() == timeclone.get_day(); +assert time.get_hour() == timeclone.get_hour(); +assert time.get_minute() == timeclone.get_minute(); +assert time.get_second() == timeclone.get_second(); +assert time.get_is_date() == timeclone.get_is_date(); +assert time.get_is_daylight() == timeclone.get_is_daylight(); +assert time.get_zone() == timeclone.get_zone(); +assert time.is_utc() == timeclone.is_utc(); + timeclone = ICalGLib.Timetype.new_clone(time); assert time != timeclone; assert ICalGLib.Timetype.get_year(time) == ICalGLib.Timetype.get_year(timeclone); |