utils: add helper method for component construction
This commit is contained in:
@@ -397,6 +397,56 @@ get_first_weekday (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const icaltimetype *initial_date,
|
||||
const icaltimetype *final_date)
|
||||
{
|
||||
ECalComponent *event;
|
||||
|
||||
ECalComponentDateTime dt;
|
||||
ECalComponentText summ;
|
||||
icaltimetype *dt_start;
|
||||
|
||||
event = e_cal_component_new ();
|
||||
e_cal_component_set_new_vtype (event, E_CAL_COMPONENT_EVENT);
|
||||
|
||||
dt_start = gcal_dup_icaltime (initial_date);
|
||||
dt.value = dt_start;
|
||||
dt.tzid = NULL;
|
||||
e_cal_component_set_dtstart (event, &dt);
|
||||
|
||||
if (final_date != NULL)
|
||||
{
|
||||
*dt.value = *final_date;
|
||||
e_cal_component_set_dtend (event, &dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
icaltime_adjust (dt_start, 1, 0, 0, 0);
|
||||
*dt.value = *dt_start;
|
||||
e_cal_component_set_dtend (event, &dt);
|
||||
}
|
||||
|
||||
summ.altrep = NULL;
|
||||
summ.value = summary;
|
||||
e_cal_component_set_summary (event, &summ);
|
||||
|
||||
e_cal_component_commit_sequence (event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/* Function to do a last minute fixup of the AM/PM stuff if the locale
|
||||
* and gettext haven't done it right. Most English speaking countries
|
||||
* except the USA use the 24 hour clock (UK, Australia etc). However
|
||||
|
||||
@@ -86,6 +86,10 @@ gchar* get_uuid_from_component (ESource
|
||||
|
||||
gint get_first_weekday (void);
|
||||
|
||||
ECalComponent* build_component_from_details (const gchar *summary,
|
||||
const icaltimetype *initial_date,
|
||||
const icaltimetype *final_date);
|
||||
|
||||
/* code brought from evolution */
|
||||
gsize e_strftime_fix_am_pm (gchar *str,
|
||||
gsize max,
|
||||
|
||||
Reference in New Issue
Block a user