Bug 42899 - incorrect event recurrance when even spans multiple days
Summary: incorrect event recurrance when even spans multiple days
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: otherviews (show other bugs)
Version: 2.2.1
Platform: Mandrake RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords: triaged
: 72770 87153 89992 93706 95918 106400 109763 112483 122390 122945 130109 142560 145317 149225 150478 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-05-21 20:18 UTC by Rance Hall
Modified: 2009-03-07 06:24 UTC (History)
25 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rance Hall 2002-05-21 20:15:05 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           korganizer
Version:           2.2.1 (using KDE 2.2.2 )
Severity:          normal
Installed from:    Mandrake RPMs
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Mandrake 8.2 default rpms unknown compiler version

create an even that concludes at midnight.

Midnight is the first hour of the next day so you should have an even that spans two days.

Make this even a recurring even for the same day each week.

In my example I had recurring meeting on friday from 9pm to 12:00 AM the next morning.

The even will not display in the calendar view of subsequent dates of the evens supposed occurance.

In my examply none of the Fridays except the first showed the event.

My fix was to change the completion time to 11:45 (thus it was a one day event) and it recurred properly.

(Submitted via bugs.kde.org)
(Called from KBugReport dialog. Fields Application KDE Version OS Compiler manually changed)
Comment 1 Cornelius Schumacher 2002-09-30 01:13:09 UTC
KOrganizer apparently doesn't handle 12 pm as end date correctly. 

*** This bug has been marked as a duplicate of 34479 ***
Comment 2 Cornelius Schumacher 2002-10-08 22:49:29 UTC
Recurring multi-day events aren't shown in the agenda view. 
Comment 3 Reinhold Kainhofer 2003-09-22 14:27:19 UTC
Shall we just disable the recurrence checkbox in the event editor if the start 
date != end date of the event? This would at least remove the confusion from 
the user who expects to see the recurrences in the calendar. 
 
We would of course also need to add a comment somewhere that only one-day 
events can recur, but not events spanning multiple days. 
 
Reinhold 
Comment 4 Cornelius Schumacher 2003-09-22 14:32:07 UTC
This would be ok as a workaround if we aren't able to fix the bug before the 
release, but of course it would be much more preferable to actually fix this 
bug. 
 
Comment 5 Reinhold Kainhofer 2003-09-22 14:52:03 UTC
Subject: Re:  incorrect event recurrance when even spans multiple days

I don't think we can fix the bug that easy (to make it for KDE 3.2), as 
several places in korganizer's code have a structure like:

if (event->doesRecur()) {
  // treat recurring items here, assumes they are only one-day events
  // display date is not start/end date as stored in event
} else {
  if (event->isMultiDay()) {
    // treat multi-day items, assume they don't recur 
    // i.e. really use the dates stored in the event.
  } else {
    // treat all single-day, non-recurring events here
  }
}

All such code needs to be rewritten, and that is not feasible before the 
release. 

Reinhold
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/bvBOTqjEwhXvPN0RAnQMAKCRI9jY24IKVPukI3qpoMbRUV44yACfQTxg
GGqrVDQsnGAzM2BCPxU+cGE=
=kMW5
-----END PGP SIGNATURE-----

Comment 6 Reinhold Kainhofer 2004-01-17 18:29:51 UTC
*** Bug 72770 has been marked as a duplicate of this bug. ***
Comment 7 Reinhold Kainhofer 2004-08-14 13:44:11 UTC
*** Bug 87153 has been marked as a duplicate of this bug. ***
Comment 8 Reinhold Kainhofer 2004-09-22 10:28:27 UTC
*** Bug 89992 has been marked as a duplicate of this bug. ***
Comment 9 Brian 2004-10-17 04:58:16 UTC
I think your definition of isMultiDay is incorrect.  Would you say the range of real numbers from -1 to 0 enters the positive numbers?  No.  0 is not positive.  Midnight is not the next day.  After midnight is the next day.  I haven't seen the code, but this feels like a < versus <= problem.
Comment 10 Reinhold Kainhofer 2004-10-17 10:10:55 UTC
On Sunday 17 October 2004 04:58, Brian wrote:
> ------- Additional Comments From brian_252 yahoo com  2004-10-17 04:58
> ------- I think your definition of isMultiDay is incorrect.  Would you say
> the range of real numbers from -1 to 0 enters the positive numbers?  No.  0
> is not positive.  

But it's non-negative. Think of the negative numbers as the previous day. 
Clearly 0 is not contained therein.

> Midnight is not the next day.  

It is by definition: 12 am on the next day


> After midnight is the next  day. 
> I haven't seen the code, but this feels like a < versus <= problem. 

Yes, I know this. RFC 2445 (the iCalendar specification) even says that 
end-times are non-inclusive, so of course these events are one one-day 
events, not multi-day events. I just haven't found the place in the code yet 
where one needs to change this.

However, the problem of multi-day recurring events not being displayed is a 
more general problem...

Reinhold
Comment 11 Reinhold Kainhofer 2004-11-22 09:44:09 UTC
*** Bug 93706 has been marked as a duplicate of this bug. ***
Comment 12 Reinhold Kainhofer 2005-02-13 12:44:15 UTC
*** Bug 95918 has been marked as a duplicate of this bug. ***
Comment 13 Reinhold Kainhofer 2005-07-23 11:26:17 UTC
*** Bug 106400 has been marked as a duplicate of this bug. ***
Comment 14 Reinhold Kainhofer 2005-07-28 14:28:50 UTC
*** Bug 109763 has been marked as a duplicate of this bug. ***
Comment 15 Reinhold Kainhofer 2005-07-30 15:47:46 UTC
SVN commit 440434 by kainhofe:

Use the new methods in the Incidence class to obtain the list of start times for all occurrences that overlap with the given day. This makes printing multi-day recurring events possible. They are not yet correctly shown in the Agenda, though.

CCBUG: 42899


 M  +16 -27    calprinthelper.cpp  


--- branches/KDE/3.5/kdepim/korganizer/printing/calprinthelper.cpp #440433:440434
@@ -64,8 +64,8 @@
 class PrintCellItem : public KOrg::CellItem
 {
   public:
-    PrintCellItem( Event *event, const QDate &day )
-      : mEvent( event ), mDay( day )
+    PrintCellItem( Event *event, const QDateTime &start, const QDateTime &end )
+      : mEvent( event ), mStart( start), mEnd( end )
     {
     }
 
@@ -73,25 +73,15 @@
 
     QString label() const { return mEvent->summary(); }
 
+    QDateTime start() const { return mStart; }
+    QDateTime end() const { return mEnd; }
+
+    /** Calculate the start and end date/time of the recurrence that
+        happens on the given day */
     bool overlaps( KOrg::CellItem *o ) const
     {
       PrintCellItem *other = static_cast<PrintCellItem *>( o );
 
-      QDateTime start = event()->dtStart();
-      QDateTime end = event()->dtEnd();
-// FIXME: This breaks with recurring multi-day events!
-      if ( event()->doesRecur() ) {
-        start.setDate( mDay );
-        end.setDate( mDay );
-      }
-      QDateTime otherStart = other->event()->dtStart();
-      QDateTime otherEnd = other->event()->dtEnd();
-// FIXME: This breaks with recurring multi-day events!
-      if ( other->event()->doesRecur() ) {
-        otherStart.setDate( mDay );
-        otherEnd.setDate( mDay );
-      }
-
 #if 0
       kdDebug(5850) << "PrintCellItem::overlaps() " << event()->summary()
                     << " <-> " << other->event()->summary() << endl;
@@ -101,12 +91,12 @@
       kdDebug(5850) << "  otherEnd  : " << otherEnd.toString() << endl;
 #endif
 
-      return !( otherStart >= end || otherEnd <= start );
+      return !( other->start() >= end() || other->end() <= start() );
     }
 
   private:
     Event *mEvent;
-    QDate mDay;
+    QDateTime mStart, mEnd;
 };
 
 CalPrintHelper::CalPrintHelper( KPrinter *pr, Calendar *cal, KConfig *cfg,
@@ -480,7 +470,11 @@
 
   Event::List::ConstIterator itEvents;
   for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
-    cells.append( new PrintCellItem( *itEvents, qd ) );
+    QValueList<QDateTime> times = (*itEvents)->startDateTimesForDate( qd );
+    for ( QValueList<QDateTime>::ConstIterator it = times.begin();
+          it != times.end(); ++it ) {
+      cells.append( new PrintCellItem( *itEvents, (*it), (*itEvents)->endDateForStart( *it ) ) );
+    }
   }
 
   QPtrListIterator<KOrg::CellItem> it1( cells );
@@ -525,13 +519,8 @@
   if ( mUseColors ) setCategoryColors( p, event );
 
   // start/end of print area for event
-  QDateTime startTime = event->dtStart();
-  QDateTime endTime = event->dtEnd();
-// FIXME: This breaks with recurring multi-day events!
-  if ( event->doesRecur() ) {
-    startTime.setDate( qd );
-    endTime.setDate( qd );
-  }
+  QDateTime startTime = item->start();
+  QDateTime endTime = item->end();
   if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
        ( endTime > startPrintDate && startTime < endPrintDate ) ) {
     if ( startTime < startPrintDate ) startTime = startPrintDate;
Comment 16 Harlan 2006-02-13 18:14:19 UTC
Currently, my schedule runs from 21:30 to 06:00.  I would like to add this as a SINGLE recurring entry instead of multiple, broken up, entries.

My system details:
Linux 2.6.15-gentoo-r1
KDE 3.4.3
Korganizer 3.4.2
Comment 17 Ulf Dietrich 2006-02-21 18:42:40 UTC
In Ver 3.5 of korganizer in kde 3.5.1 the Agenda isn't correctly shown. I'll think that is great reduction of functionality in korganizer. Please check the follow example to understand what i mean.
Make a new ewent "Sample". Then go to reccurance and enable it. Leave the form with OK. Than take a look at the Agenda in the next week and you see the event.
Now go back to the "Sample" and double klick on it. Now set the date of the end of this appointment to the next day. After closing with OK go back to the agenda and look at the future week's. There is no event shown. I'll can't understand this Bug, because the event's were right shown in the "monthly" view.
Thank you for your Work
Comment 18 Thomas Steudten 2006-05-23 17:40:21 UTC
This bug is still open in korganizer! And this since 2002!
Comment 19 F Reifenstahl 2006-07-07 13:12:46 UTC
I recently discovered that multi-day appointments resolve into single day appointments in whole day area when defined as recurrent, defined nonrecurring they figure correctly as a continuos block. Rummaging bugs.kde.org has lead me here, I hope I am on the beam. Hoping, too, that this bug will soon be patched.
Comment 20 Reinhold Kainhofer 2006-11-02 19:23:39 UTC
Reassigning all KOrganizer bug reports and wishes to the newly created 
korganizer-devel mailing list.
Comment 21 Reinhold Kainhofer 2006-12-31 19:05:31 UTC
*** Bug 130109 has been marked as a duplicate of this bug. ***
Comment 22 Reinhold Kainhofer 2006-12-31 19:07:25 UTC
*** Bug 122945 has been marked as a duplicate of this bug. ***
Comment 23 Reinhold Kainhofer 2006-12-31 19:09:33 UTC
*** Bug 112483 has been marked as a duplicate of this bug. ***
Comment 24 Reinhold Kainhofer 2006-12-31 19:20:06 UTC
*** Bug 122390 has been marked as a duplicate of this bug. ***
Comment 25 Glenn 2007-06-19 18:06:07 UTC
As the reporter of bug 130109, I'm wondering if this old bug is on tap to be resolved in KDE 4.0. 
Comment 26 FiNeX 2008-09-28 19:23:20 UTC
It has been fixed in KDE4.
Comment 27 Folken 2008-09-28 23:11:07 UTC
I'm sorry but i must disagree. The bug is still present in korganizer 4.1.0.
Comment 28 FiNeX 2008-09-28 23:59:40 UTC
@Folken: can you tell me exactly the steps to reproduce it?

I've created an recurring event which end at midnight, this event and all recurrences are displayed correctly, even using KDE 3.5.10. Maybe I've miss something for the test?
Comment 29 FiNeX 2008-09-29 02:07:04 UTC
Folken wrote: 
> Create an event going past midnight. e.g. 2am of the next day. Now mark
> the event reoccur weekly. Switch to Month view and you will see the
> event repeat. Switch back to week view and you will see it in the week
> you entered it, but switch to the following week and the reoccurring
> event is no longer displayed. 

Thanks Folken, doing this step, I've reproduced it.
Comment 30 Jaime Torres 2008-11-23 12:19:53 UTC
With KDE 4.1.73 (KDE 4.1.72 (KDE 4.2 >= 20081112)) "release 3.3", reproduced it using comment #23 steps.
Comment 31 Sergio Martins 2008-12-27 03:43:10 UTC
I'm working on this, expect it fixed in trunk soon.
Comment 32 Sergio Martins 2008-12-27 04:01:50 UTC
*** Bug 142560 has been marked as a duplicate of this bug. ***
Comment 33 Sergio Martins 2009-01-25 07:52:24 UTC
*** Bug 145317 has been marked as a duplicate of this bug. ***
Comment 34 Sergio Martins 2009-01-27 00:32:34 UTC
SVN commit 917150 by smartins:

Performance improvement in agendaview and support for multi-day recurring events in korganizer. Use timesInInterval() in 
KOAgendaView::fillAgenda()

Discussion at http://reviewboard.vidsolbach.de/r/358/

BUG: 42899



 M  +109 -84   koagendaview.cpp  
 M  +1 -1      koagendaview.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=917150
Comment 35 Sergio Martins 2009-02-02 05:21:11 UTC
*** Bug 150478 has been marked as a duplicate of this bug. ***
Comment 36 Sergio Martins 2009-03-07 06:24:24 UTC
*** Bug 149225 has been marked as a duplicate of this bug. ***