[Kolab-devel] Bug#748614: [libkolab0] looses information about birthdays

Sven Eckelmann <[email protected]>
Newsgroups gmane.comp.kde.devel.kolab
Message-ID <2679848.eKV6P1RDkS__31907.2991762825$1408973158$gmane$org@sven-edge>
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

_______________________________________________
devel mailing list
[email protected]
https://lists.kolab.org/mailman/listinfo/devel
0001-Allow-KDateTime-with-only-valid-date.patch (text/x-patch, 1.5 KB)
From a90b7696d6e21d17d4dbe1225a2671704db92014 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.