summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-19 10:19:59 (UTC)
committer zautrix <zautrix>2005-02-19 10:19:59 (UTC)
commitd2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3 (patch) (side-by-side diff)
treed57e0a39b6c15b9108c260359fa19986e4823741
parent59a00e603e2ba14885e81c09daf3bb89859ff176 (diff)
downloadkdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.zip
kdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.tar.gz
kdepimpi-d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3.tar.bz2
duration fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--libkcal/icalformatimpl.cpp31
-rw-r--r--libkcal/incidencebase.cpp11
3 files changed, 27 insertions, 17 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 06aa5f6..01d9e27 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -12,4 +12,6 @@ Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
and made it configureable to show these values.
+Fixed a problem for events (from external iCal files) that do have a duration but no end date.
+
********** VERSION 2.0.7 ************
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2e38ae3..eae41aa 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -409,9 +409,9 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
// turned off as it always is set to PTS0 (and must not occur together with DTEND
-// if (incidence->hasDuration()) {
-// icaldurationtype duration;
-// duration = writeICalDuration(incidence->duration());
-// icalcomponent_add_property(parent,icalproperty_new_duration(duration));
-// }
+ if (incidence->hasDuration()) {
+ icaldurationtype duration;
+ duration = writeICalDuration(incidence->duration());
+ icalcomponent_add_property(parent,icalproperty_new_duration(duration));
+ }
}
@@ -1770,15 +1770,16 @@ icaldurationtype ICalFormatImpl::writeICalDuration(int seconds)
icaldurationtype d;
- d.weeks = seconds % gSecondsPerWeek;
- seconds -= d.weeks * gSecondsPerWeek;
- d.days = seconds % gSecondsPerDay;
- seconds -= d.days * gSecondsPerDay;
- d.hours = seconds % gSecondsPerHour;
- seconds -= d.hours * gSecondsPerHour;
- d.minutes = seconds % gSecondsPerMinute;
- seconds -= d.minutes * gSecondsPerMinute;
+ d.is_neg = (seconds<0)?1:0;
+ if (seconds<0) seconds = -seconds;
+
+ d.weeks = seconds / gSecondsPerWeek;
+ seconds %= gSecondsPerWeek;
+ d.days = seconds / gSecondsPerDay;
+ seconds %= gSecondsPerDay;
+ d.hours = seconds / gSecondsPerHour;
+ seconds %= gSecondsPerHour;
+ d.minutes = seconds / gSecondsPerMinute;
+ seconds %= gSecondsPerMinute;
d.seconds = seconds;
- d.is_neg = 0;
-
return d;
}
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 51f2e9d..1e99082 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -107,4 +107,13 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
#endif
+ if ( i1.hasDuration() == i2.hasDuration() ) {
+ if ( i1.hasDuration() ) {
+ if ( i1.duration() != i2.duration() )
+ return false;
+ }
+ } else {
+ return false;
+ }
+
return ( i1.organizer() == i2.organizer() &&
// i1.uid() == i2.uid() &&
@@ -112,6 +121,4 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
// of much use. We are not comparing for identity, after all.
i1.doesFloat() == i2.doesFloat() &&
- i1.duration() == i2.duration() &&
- i1.hasDuration() == i2.hasDuration() &&
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver