From 9a69a192221d827f263e6972b9f07031b62676ef Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 15 Jan 2009 14:48:21 +0000 Subject: ** Fix for bug #245156 2009-01-15 Milan Crha ** Fix for bug #245156 * gui/e-day-view.c: (e_day_view_finish_long_event_resize), (e_day_view_finish_resize), (e_day_view_change_event_time), (e_day_view_on_top_canvas_drag_data_received), (e_day_view_on_main_canvas_drag_data_received): * gui/e-week-view.c: (e_week_view_change_event_time): * gui/e-calendar-view.c: (on_unrecur_appointment): Keep old timezone for dtstart/dtend when changing it. * gui/comp-util.h: (cal_comp_set_dtstart_with_oldzone), (cal_comp_set_dtend_with_oldzone): * gui/comp-util.c: (cal_comp_set_dtstart_with_oldzone), (cal_comp_set_dtend_with_oldzone), (datetime_to_zone): Helper functions to make it easier. svn path=/trunk/; revision=37079 --- calendar/gui/comp-util.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 0e63a9c336..9504c7bda7 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -530,3 +530,80 @@ cal_comp_selection_get_string_list (GtkSelectionData *data) return list; } + +static void +datetime_to_zone (ECal *client, ECalComponentDateTime *date, const char *tzid) +{ + icaltimezone *from, *to; + + g_return_if_fail (date != NULL); + + if (date->tzid == NULL || tzid == NULL || + date->tzid == tzid || g_str_equal (date->tzid, tzid)) + return; + + from = icaltimezone_get_builtin_timezone_from_tzid (date->tzid); + if (!from) { + if (!e_cal_get_timezone (client, date->tzid, &from, NULL)) + g_warning ("%s: Could not get timezone from server: %s", G_STRFUNC, date->tzid ? date->tzid : ""); + } + + to = icaltimezone_get_builtin_timezone_from_tzid (tzid); + if (!to) { + /* do not check failure here, maybe the zone is not available there */ + e_cal_get_timezone (client, tzid, &to, NULL); + } + + icaltimezone_convert_time (date->value, from, to); + date->tzid = tzid; +} + +/** + * cal_comp_set_dtstart_with_oldzone: + * Changes 'dtstart' of the component, but converts time to the old timezone. + * @param client ECal structure, to retrieve timezone from, when required. + * @param comp Component, where make the change. + * @param pdate Value, to change to. + **/ +void +cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) +{ + ECalComponentDateTime olddate, date; + + g_return_if_fail (comp != NULL); + g_return_if_fail (pdate != NULL); + + e_cal_component_get_dtstart (comp, &olddate); + + date = *pdate; + + datetime_to_zone (client, &date, olddate.tzid); + e_cal_component_set_dtstart (comp, &date); + + e_cal_component_free_datetime (&olddate); +} + +/** + * cal_comp_set_dtend_with_oldzone: + * Changes 'dtend' of the component, but converts time to the old timezone. + * @param client ECal structure, to retrieve timezone from, when required. + * @param comp Component, where make the change. + * @param pdate Value, to change to. + **/ +void +cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) +{ + ECalComponentDateTime olddate, date; + + g_return_if_fail (comp != NULL); + g_return_if_fail (pdate != NULL); + + e_cal_component_get_dtend (comp, &olddate); + + date = *pdate; + + datetime_to_zone (client, &date, olddate.tzid); + e_cal_component_set_dtend (comp, &date); + + e_cal_component_free_datetime (&olddate); +} -- cgit v1.2.3