/** * e_cal_util_get_system_timezone: * * Fetches system timezone icaltimezone object. * * The returned pointer is part of the built-in timezones and should not be freed. * * Returns: (transfer none): The icaltimezone object of the system timezone, or %NULL on an error. * * Since: 2.28 **/ icaltimezone * e_cal_util_get_system_timezone (void) { gchar *location; icaltimezone *zone; location = e_cal_system_timezone_get_location (); g_return_val_if_fail (location != NULL, NULL); zone = icaltimezone_get_builtin_timezone (location); g_free (location); return zone; }
static void app_update_timezone (App *app) { gchar *location; location = e_cal_system_timezone_get_location (); if (g_strcmp0 (location, app->timezone_location) != 0) { if (location == NULL) app->zone = icaltimezone_get_utc_timezone (); else app->zone = icaltimezone_get_builtin_timezone (location); g_free (app->timezone_location); app->timezone_location = location; print_debug ("Using timezone %s", app->timezone_location); } }
/** * e_cal_util_get_system_timezone_location: * * Fetches system timezone localtion string. * * Returns: (transfer full): system timezone location string, %NULL on an error. * * Since: 2.28 **/ gchar * e_cal_util_get_system_timezone_location (void) { return e_cal_system_timezone_get_location (); }
/** * build_component_from_details: * @summary: * @initial_date: * @final_date: * * Create a component with the provided details * * Returns: (Transfer full): an {@link ECalComponent} object **/ ECalComponent* build_component_from_details (const gchar *summary, GDateTime *initial_date, GDateTime *final_date) { ECalComponent *event; ECalComponentDateTime dt; ECalComponentText summ; icaltimezone *zone; gboolean all_day; event = e_cal_component_new (); e_cal_component_set_new_vtype (event, E_CAL_COMPONENT_EVENT); /* * Check if the event is all day. Notice that it can be all day even * without the final date. */ all_day = datetime_is_date (initial_date) && (final_date ? datetime_is_date (final_date) : TRUE); /* * When the event is all day, we consider UTC timezone by default. Otherwise, * we always use the system timezone to create new events */ if (all_day) { zone = icaltimezone_get_utc_timezone (); } else { gchar *system_tz = e_cal_system_timezone_get_location (); zone = icaltimezone_get_builtin_timezone (system_tz); g_free (system_tz); } /* Start date */ dt.value = datetime_to_icaltime (initial_date); icaltime_set_timezone (dt.value, zone); dt.value->is_date = all_day; dt.tzid = icaltimezone_get_tzid (zone); e_cal_component_set_dtstart (event, &dt); g_free (dt.value); /* End date */ if (!final_date) final_date = g_date_time_add_days (initial_date, 1); dt.value = datetime_to_icaltime (final_date); icaltime_set_timezone (dt.value, zone); dt.value->is_date = all_day; dt.tzid = icaltimezone_get_tzid (zone); e_cal_component_set_dtend (event, &dt); g_free (dt.value); /* Summary */ summ.altrep = NULL; summ.value = summary; e_cal_component_set_summary (event, &summ); e_cal_component_commit_sequence (event); return event; }