[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkdepimlibs=5D_/=3A_Fix_calculation_of_the_next_due_?=
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2011-02-06 1:19:55
Message-ID: 20110206011955.E7EB0A60B4 () git ! kde ! org
[Download RAW message or body]

Git commit e82855e966911a8605b3c34b411e4f4bc1cf446a by Sergio Martins.
Committed on 06/02/11 at 02:16.
Pushed by smartins into branch 'master'.

Fix calculation of the next due date for all day to-dos.

The reason we must use "<" for date only, but "<=" for ocurrences with time is that
if it's date only, the user can still complete that ocurrence today, so that's
the current ocurrence that needs completing.

Will make a unit test.

M  +14   -3    kcalcore/todo.cpp     

http://commits.kde.org/kdepimlibs/e82855e966911a8605b3c34b411e4f4bc1cf446a

diff --git a/kcalcore/todo.cpp b/kcalcore/todo.cpp
index 5f86429..d2c5a79 100644
--- a/kcalcore/todo.cpp
+++ b/kcalcore/todo.cpp
@@ -455,9 +455,20 @@ bool Todo::Private::recurTodo( Todo *todo )
     if ( ( r->duration() == -1 ||
            ( nextOccurrenceDateTime.isValid() && recurrenceEndDateTime.isValid() &&
              nextOccurrenceDateTime <= recurrenceEndDateTime ) ) ) {
-      const KDateTime rightNow = KDateTime::currentUtcDateTime();
-      while ( !todo->recursAt( nextOccurrenceDateTime ) ||
-              nextOccurrenceDateTime <=  ) {
+      // We convert to the same timeSpec so we get the correct .date()
+      const KDateTime rightNow = KDateTime::currentUtcDateTime().toTimeSpec( \
nextOccurrenceDateTime.timeSpec() ); +      const bool isDateOnly = todo->allDay();
+
+      /* Now we search for the occurrence that's _after_ the currentUtcDateTime, or
+       * if it's dateOnly, the occurrrence that's _during or after today_.
+       * The reason we use "<" for date only, but "<=" for ocurrences with time is \
that +       * if it's date only, the user can still complete that ocurrence today, \
so that's +       * the current ocurrence that needs completing.
+       */
+      while ( !todo->recursAt( nextOccurrenceDateTime )                ||
+              ( !isDateOnly && nextOccurrenceDateTime <= rightNow )    ||
+              ( isDateOnly && nextOccurrenceDateTime.date() < rightNow.date() ) ) {
+
         if ( !nextOccurrenceDateTime.isValid() ||
              ( nextOccurrenceDateTime > recurrenceEndDateTime && r->duration() != -1 \
) ) {  return false;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic