Fixed support for libical version prior to 3. This is required for libkcal tests to work fine on older distributions.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/18/head
Michele Calgaro 5 years ago
parent 48af72cbe8
commit 858a7e560a
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -12,8 +12,13 @@
# libical
pkg_search_module( LIBICAL libical )
if( LIBICAL_FOUND )
# check for libical >= 3.0
if( NOT (LIBICAL_VERSION VERSION_LESS "3.0") )
add_definitions(-DUSE_LIBICAL_3_0)
endif( )
# check for libical >= 0.46
if( NOT (LIBICAL_VERSION VERSION_LESS "0.46") )
set( USE_LIBICAL_0_46 1 CACHE INTERNAL "" FORCE )
add_definitions(-DUSE_LIBICAL_0_46)
endif( )
else( )
tde_message_fatal( "libical are required, but not found on your system" )

@ -1932,6 +1932,9 @@ icaltimetype ICalFormatImpl::writeICalDate(const TQDate &date)
t.second = 0;
t.is_date = 1;
#ifndef USE_LIBICAL_3_0
t.is_utc = 0;
#endif
t.zone = 0;
return t;
@ -1951,6 +1954,9 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const TQDateTime &datetime)
t.is_date = 0;
t.zone = icaltimezone_get_builtin_timezone ( mParent->timeZoneId().latin1() );
#ifndef USE_LIBICAL_3_0
t.is_utc = 0;
#endif
// _dumpIcaltime( t );
/* The TQDateTime we get passed in is to be considered in the timezone of
@ -1965,6 +1971,9 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const TQDateTime &datetime)
t.zone = tz;
t = icaltime_convert_to_zone( t, utc );
} else {
#ifndef USE_LIBICAL_3_0
t.is_utc = 1;
#endif
t.zone = utc;
}
}
@ -1976,7 +1985,12 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const TQDateTime &datetime)
TQDateTime ICalFormatImpl::readICalDateTime( icalproperty *p, icaltimetype& t, icaltimezone* tz )
{
// kdDebug(5800) << "ICalFormatImpl::readICalDateTime()" << endl;
if (!icaltime_is_utc(t)) { // Only use the TZ if time is not UTC.
#ifdef USE_LIBICAL_3_0
bool time_is_utc = icaltime_is_utc(t);
#else
bool time_is_utc = t.is_utc;
#endif
if ( !time_is_utc ) { // Only use the TZ if time is not UTC.{
// FIXME: We'll need to make sure to apply the appropriate TZ, not just
// the first one found.
icalparameter *param = p ? icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER) : 0;
@ -1992,9 +2006,15 @@ TQDateTime ICalFormatImpl::readICalDateTime( icalproperty *p, icaltimetype& t, i
}
else {
if (tz && tz != icaltimezone_get_utc_timezone()) {
#ifndef USE_LIBICAL_3_0
t.is_utc = 0;
#endif
t.zone = tz;
}
else {
#ifndef USE_LIBICAL_3_0
t.is_utc = 1;
#endif
t.zone = icaltimezone_get_utc_timezone();
}
}

Loading…
Cancel
Save