From 48af72cbe8a4f0cc22de3e2ceda5db47ca922759 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 27 Mar 2019 23:27:22 +0900 Subject: Fixed bug in libkcal related to timezones in DT field. Fixed execution of libkcal tests. This resolves bug 2719. Signed-off-by: Michele Calgaro --- libkcal/icalformat.cpp | 2 +- libkcal/icalformatimpl.cpp | 36 ++++++++++++---------- libkcal/tests/CMakeLists.txt | 8 +++-- .../LibICal/LibICal_TestCase06.ics.next.ref | 20 ++++++------ .../LibICal/LibICal_TestCase06.ics.prev.ref | 20 ++++++------ .../LibICal/LibICal_TestCase07.ics.next.ref | 6 ++-- .../LibICal/LibICal_TestCase07.ics.prev.ref | 6 ++-- .../LibICal/LibICal_TestCase15.ics.next.ref | 12 ++++---- .../LibICal/LibICal_TestCase15.ics.prev.ref | 12 ++++---- .../LibICal/LibICal_TestCase54.ics.next.ref | 12 ++++---- .../LibICal/LibICal_TestCase54.ics.prev.ref | 12 ++++---- .../LibICal/LibICal_TestCase55.ics.next.ref | 2 +- .../LibICal/LibICal_TestCase55.ics.prev.ref | 2 +- 13 files changed, 78 insertions(+), 72 deletions(-) (limited to 'libkcal') diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp index 52f4777ea..ab0ab5323 100644 --- a/libkcal/icalformat.cpp +++ b/libkcal/icalformat.cpp @@ -149,7 +149,7 @@ bool ICalFormat::fromRawString( Calendar *cal, const TQCString &text ) // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components icalcomponent *calendar; - // Let's defend const correctness until the very gates of hell^Wlibical + // Let's defend const correctness until the very gates of hell calendar = icalcomponent_new_from_string( const_cast( (const char*)text ) ); // kdDebug(5800) << "Error: " << icalerror_perror() << endl; if (!calendar) { diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 171fe8f82..0c7b40e25 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -1976,24 +1976,28 @@ icaltimetype ICalFormatImpl::writeICalDateTime(const TQDateTime &datetime) TQDateTime ICalFormatImpl::readICalDateTime( icalproperty *p, icaltimetype& t, icaltimezone* tz ) { // kdDebug(5800) << "ICalFormatImpl::readICalDateTime()" << endl; - if (tz && !icaltime_is_utc(t)) { // Only use the TZ if time is not UTC. + if (!icaltime_is_utc(t)) { // 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. - if (tz != icaltimezone_get_utc_timezone()) { - icalparameter *param = p ? icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER) : 0; - const char *tzid = param ? icalparameter_get_tzid(param) : 0; - if ( !tzid ) - t.zone = tz; - else { - icaltimezone* icaltz; - // Try to match the ID with the libical time zone's location property - icaltz = icaltimezone_get_builtin_timezone( tzid ); - if ( icaltz ) { -// kdDebug(5800) << "ICalFormatImpl::readICalDateTime(): time zone '" << tzid << "' read from libical database" << endl; - } - t.zone = icaltz; - } - } + icalparameter *param = p ? icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER) : 0; + const char *tzid = param ? icalparameter_get_tzid(param) : 0; + if ( tzid ) { + icaltimezone* icaltz; + // Try to match the ID with the libical time zone's location property + icaltz = icaltimezone_get_builtin_timezone( tzid ); + if ( icaltz ) { + //kdDebug(5800) << "ICalFormatImpl::readICalDateTime(): time zone '" << tzid << "' read from libical database" << endl; + } + t.zone = icaltz; + } + else { + if (tz && tz != icaltimezone_get_utc_timezone()) { + t.zone = tz; + } + else { + t.zone = icaltimezone_get_utc_timezone(); + } + } } else { t.zone = icaltimezone_get_utc_timezone(); } diff --git a/libkcal/tests/CMakeLists.txt b/libkcal/tests/CMakeLists.txt index 386982c4d..3f3603d45 100644 --- a/libkcal/tests/CMakeLists.txt +++ b/libkcal/tests/CMakeLists.txt @@ -59,13 +59,15 @@ add_custom_command( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) +# Compat tests are broken and have been in a disabled state since before TDE exited set ( _test1 testrecurrence "next" ${CMAKE_CURRENT_SOURCE_DIR}/data/RecurrenceRule/*.ics ) set ( _test2 testrecurprevious "prev" ${CMAKE_CURRENT_SOURCE_DIR}/data/RecurrenceRule/*.ics ) set ( _test3 testrecurson "recurson" ${CMAKE_CURRENT_SOURCE_DIR}/data/RecurrenceRule/*.ics ) -set ( _test4 readandwrite "ical" ${CMAKE_CURRENT_SOURCE_DIR}/data/Compat/*.ics ) +#set ( _test4 readandwrite "ical" ${CMAKE_CURRENT_SOURCE_DIR}/data/Compat/*.ics ) set ( _test5 testvcalexport "vcal" ${CMAKE_CURRENT_SOURCE_DIR}/data/vCalendar/*.ics ) set ( _test6 readandwrite "ical" ${CMAKE_CURRENT_SOURCE_DIR}/data/vCalendar/*.vcs ) -set ( _all_tests _test1 _test2 _test3 _test4 _test5 _test6 ) +#set ( _all_tests _test1 _test2 _test3 _test4 _test5 _test6 ) +set ( _all_tests _test1 _test2 _test3 _test5 _test6 ) foreach( _test_name ${_all_tests} ) list( GET ${_test_name} 0 _test_executable ) @@ -74,7 +76,7 @@ foreach( _test_name ${_all_tests} ) file( GLOB_RECURSE _test_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${_test_search_filter} ) foreach( _test_file ${_test_files} ) add_test( - ${_test_executable}__${_test_file}__ + ${_test_executable}__${_test_id}__${_test_file}__ ${CMAKE_CURRENT_SOURCE_DIR}/runtestcase.pl ${_test_executable} ${_test_id} ${CMAKE_CURRENT_BINARY_DIR}/${_test_file} ) endforeach( ) diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.next.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.next.ref index 0abed481e..c34698184 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.next.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.next.ref @@ -1,13 +1,13 @@ -2001-12-16T19:25:00 -2001-12-18T19:25:00 -2001-12-23T19:25:00 -2001-12-25T19:25:00 -2001-12-30T19:25:00 -2002-01-01T19:25:00 -2002-01-06T19:25:00 -2002-01-08T19:25:00 -2002-01-13T19:25:00 -2002-01-15T19:25:00 +2001-12-16T11:25:00 +2001-12-18T11:25:00 +2001-12-23T11:25:00 +2001-12-25T11:25:00 +2001-12-30T11:25:00 +2002-01-01T11:25:00 +2002-01-06T11:25:00 +2002-01-08T11:25:00 +2002-01-13T11:25:00 +2002-01-15T11:25:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.prev.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.prev.ref index 5caf88d3a..9ec6cf161 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.prev.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase06.ics.prev.ref @@ -1,13 +1,13 @@ -2002-01-15T19:25:00 -2002-01-13T19:25:00 -2002-01-08T19:25:00 -2002-01-06T19:25:00 -2002-01-01T19:25:00 -2001-12-30T19:25:00 -2001-12-25T19:25:00 -2001-12-23T19:25:00 -2001-12-18T19:25:00 -2001-12-16T19:25:00 +2002-01-15T11:25:00 +2002-01-13T11:25:00 +2002-01-08T11:25:00 +2002-01-06T11:25:00 +2002-01-01T11:25:00 +2001-12-30T11:25:00 +2001-12-25T11:25:00 +2001-12-23T11:25:00 +2001-12-18T11:25:00 +2001-12-16T11:25:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.next.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.next.ref index 9a6556470..135348004 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.next.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.next.ref @@ -1,6 +1,6 @@ -2001-12-04T15:35:00 -2002-01-01T15:35:00 -2002-02-05T15:35:00 +2001-12-04T07:35:00 +2002-01-01T07:35:00 +2002-02-05T07:35:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.prev.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.prev.ref index ba0f10788..4a782a5e8 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.prev.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase07.ics.prev.ref @@ -1,6 +1,6 @@ -2002-02-05T15:35:00 -2002-01-01T15:35:00 -2001-12-04T15:35:00 +2002-02-05T07:35:00 +2002-01-01T07:35:00 +2001-12-04T07:35:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.next.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.next.ref index 6ce39a7df..c447acf50 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.next.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.next.ref @@ -1,9 +1,9 @@ -2002-04-02T11:45:00 -2002-04-03T11:45:00 -2002-04-09T11:45:00 -2002-04-10T11:45:00 -2002-04-16T11:45:00 -2002-04-17T11:45:00 +2002-04-02T03:45:00 +2002-04-03T03:45:00 +2002-04-09T03:45:00 +2002-04-10T03:45:00 +2002-04-16T03:45:00 +2002-04-17T03:45:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.prev.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.prev.ref index 1f5f03e85..3e7925f38 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.prev.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase15.ics.prev.ref @@ -1,9 +1,9 @@ -2002-04-17T11:45:00 -2002-04-16T11:45:00 -2002-04-10T11:45:00 -2002-04-09T11:45:00 -2002-04-03T11:45:00 -2002-04-02T11:45:00 +2002-04-17T03:45:00 +2002-04-16T03:45:00 +2002-04-10T03:45:00 +2002-04-09T03:45:00 +2002-04-03T03:45:00 +2002-04-02T03:45:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.next.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.next.ref index 6ce39a7df..c447acf50 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.next.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.next.ref @@ -1,9 +1,9 @@ -2002-04-02T11:45:00 -2002-04-03T11:45:00 -2002-04-09T11:45:00 -2002-04-10T11:45:00 -2002-04-16T11:45:00 -2002-04-17T11:45:00 +2002-04-02T03:45:00 +2002-04-03T03:45:00 +2002-04-09T03:45:00 +2002-04-10T03:45:00 +2002-04-16T03:45:00 +2002-04-17T03:45:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.prev.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.prev.ref index 1f5f03e85..3e7925f38 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.prev.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase54.ics.prev.ref @@ -1,9 +1,9 @@ -2002-04-17T11:45:00 -2002-04-16T11:45:00 -2002-04-10T11:45:00 -2002-04-09T11:45:00 -2002-04-03T11:45:00 -2002-04-02T11:45:00 +2002-04-17T03:45:00 +2002-04-16T03:45:00 +2002-04-10T03:45:00 +2002-04-09T03:45:00 +2002-04-03T03:45:00 +2002-04-02T03:45:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.next.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.next.ref index 5be77173a..156bc69b6 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.next.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.next.ref @@ -1,4 +1,4 @@ -2002-04-02T11:45:00 +2002-04-02T03:45:00 diff --git a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.prev.ref b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.prev.ref index 5be77173a..156bc69b6 100644 --- a/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.prev.ref +++ b/libkcal/tests/data/RecurrenceRule/LibICal/LibICal_TestCase55.ics.prev.ref @@ -1,4 +1,4 @@ -2002-04-02T11:45:00 +2002-04-02T03:45:00 -- cgit v1.2.1