[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#732213: Bug#748614: [libkolab0] looses information about birthdays



reassign 748614 libkolab0 0.5.2-1
reassign 732213 libkolab0 0.5.2-1
forcemerge 748614 732213
retitle 748614 [libkolab0] looses information about birthdays
tags 748614 + patch upstream
forwarded 748614 https://issues.kolab.org/show_bug.cgi?id=2739
thanks

Hi,

the problem of the unsaved kaddressbook date-values doesn't seem to be in 
libkolabxml1 or kdepim-runtime but in libkolab0. I've just created a patch to 
fix it for me. Maybe this patch or a variation of it could be included as part 
of the next libkolab upload. Please also include it in the upstream bug #2739.

Kind regards,
	Sven
>From a90b7696d6e21d17d4dbe1225a2671704db92014 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 24 Aug 2014 22:14:20 +0200
Subject: [PATCH] Allow KDateTime with only valid date

The cDateTime class of libkolab returns true on .isValid() for an object with
only a valid date. But KDateTime and QDateTime only return true when both date
and time are valid. Still the conversion code relies on the fact that
KDateTime::isValid() would return true when date or date+time is true.

The code handling the conversion from/to KDateTime has to handle this
difference. Otherwise the conversion of Date-only value like KABC birthday or
anniversary would fail and therefore cause data loss.
---
 conversion/commonconversion.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/conversion/commonconversion.cpp b/conversion/commonconversion.cpp
index 7accd22..09fc04a 100644
--- a/conversion/commonconversion.cpp
+++ b/conversion/commonconversion.cpp
@@ -67,13 +67,13 @@ KDateTime toDate(const Kolab::cDateTime &dt)
         date.setTimeSpec(getTimeSpec(dt.isUTC(), dt.timezone()));
     }
     Q_ASSERT(date.timeSpec().isValid());
-    Q_ASSERT(date.isValid());
+    Q_ASSERT(date.isValid() || date.date().isValid());
     return date;
 }
 
 cDateTime fromDate(const KDateTime &dt)
 {
-    if (!dt.isValid()) {
+    if (!dt.isValid() && !dt.date().isValid()) {
         //         qDebug() << "invalid datetime converted";
         return cDateTime();
     }
-- 
2.1.0


Reply to: