static gboolean get_ical_is_all_day (icalcomponent *ical, time_t start_time, icaltimezone *default_zone) { icalproperty *prop; struct tm *start_tm; time_t end_time; struct icaldurationtype duration; struct icaltimetype start_icaltime; start_icaltime = icalcomponent_get_dtstart (ical); if (start_icaltime.is_date) return TRUE; start_tm = gmtime (&start_time); if (start_tm->tm_sec != 0 || start_tm->tm_min != 0 || start_tm->tm_hour != 0) return FALSE; if ((end_time = get_ical_end_time (ical, default_zone))) return (end_time - start_time) % 86400 == 0; prop = icalcomponent_get_first_property (ical, ICAL_DURATION_PROPERTY); if (!prop) return FALSE; duration = icalproperty_get_duration (prop); return icaldurationtype_as_int (duration) % 86400 == 0; }
static void calendar_appointment_init (CalendarAppointment *appointment, icalcomponent *ical, ECalClient *cal, icaltimezone *default_zone) { const char *source_uid; appointment->uid = get_ical_uid (ical); appointment->rid = get_ical_rid (ical); appointment->backend_name = get_source_backend_name (cal); appointment->summary = get_ical_summary (ical); appointment->description = get_ical_description (ical); appointment->color_string = get_source_color (cal); appointment->start_time = get_ical_start_time (ical, default_zone); appointment->end_time = get_ical_end_time (ical, default_zone); appointment->is_all_day = get_ical_is_all_day (ical, appointment->start_time, default_zone); /* While the UID is usually enough to identify an event, only the triple * of (source,UID,RID) is fully unambiguous; neither may contain '\n', * so we can safely use it to create a unique ID from the triple */ source_uid = e_source_get_uid (e_client_get_source (E_CLIENT (cal))); appointment->id = g_strdup_printf ("%s\n%s\n%s", source_uid, appointment->uid, appointment->rid ? appointment->rid : ""); }
static void calendar_appointment_init (CalendarAppointment *appointment, icalcomponent *ical, ECalClient *cal, icaltimezone *default_zone) { appointment->uid = get_ical_uid (ical); appointment->rid = get_ical_rid (ical); appointment->backend_name = get_source_backend_name (cal); appointment->summary = get_ical_summary (ical); appointment->description = get_ical_description (ical); appointment->color_string = get_source_color (cal); appointment->start_time = get_ical_start_time (ical, default_zone); appointment->end_time = get_ical_end_time (ical, default_zone); appointment->is_all_day = get_ical_is_all_day (ical, appointment->start_time, default_zone); }