author | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
commit | f9f521c487143641b2cf077d04fe1c475001bce2 (patch) (unidiff) | |
tree | 4ffac6d14ceb3e5d77f7634f2b2a49fd91a9e77a /libkcal/recurrence.cpp | |
parent | 66bc0202d4e2306f7029362fe09d0c7ab0e7cc36 (diff) | |
download | kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.zip kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.gz kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.bz2 |
rec fix
-rw-r--r-- | libkcal/recurrence.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index 8a175c9..6ee5499 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp | |||
@@ -976,7 +976,7 @@ bool Recurrence::recursSecondly(const QDate &qd, int secondFreq) const | |||
976 | // The date queried falls within the range of the event. | 976 | // The date queried falls within the range of the event. |
977 | if (secondFreq < 24*3600) | 977 | if (secondFreq < 24*3600) |
978 | return true; // the event recurs at least once each day | 978 | return true; // the event recurs at least once each day |
979 | int after = mRecurStart.secsTo(QDateTime(qd)); | 979 | int after = mRecurStart.secsTo(QDateTime(qd)) - 1; |
980 | if (after / secondFreq != (after + 24*3600) / secondFreq) | 980 | if (after / secondFreq != (after + 24*3600) / secondFreq) |
981 | return true; | 981 | return true; |
982 | } | 982 | } |
@@ -1188,7 +1188,7 @@ QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const | |||
1188 | break; | 1188 | break; |
1189 | 1189 | ||
1190 | case rWeekly: { | 1190 | case rWeekly: { |
1191 | QDate start = dStart.addDays(1 - dStart.dayOfWeek()); // start of week for dStart | 1191 | QDate start = dStart.addDays(-((dStart.dayOfWeek() - rWeekStart + 7)%7)); // start of week for dStart |
1192 | int earliestDayOfWeek = earliestDate.dayOfWeek(); | 1192 | int earliestDayOfWeek = earliestDate.dayOfWeek(); |
1193 | int weeksAhead = start.daysTo(earliestDate) / 7; | 1193 | int weeksAhead = start.daysTo(earliestDate) / 7; |
1194 | int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week | 1194 | int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week |
@@ -1198,9 +1198,8 @@ QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const | |||
1198 | if (!notThisWeek) | 1198 | if (!notThisWeek) |
1199 | weekday = getFirstDayInWeek(earliestDayOfWeek); | 1199 | weekday = getFirstDayInWeek(earliestDayOfWeek); |
1200 | // Check for a day in the next scheduled week | 1200 | // Check for a day in the next scheduled week |
1201 | if (!weekday && earliestDayOfWeek > 1) | 1201 | if (!weekday ) |
1202 | weekday = getFirstDayInWeek(rWeekStart) + rFreq*7; | 1202 | weekday = getFirstDayInWeek(rWeekStart) + rFreq*7; |
1203 | if (weekday) | ||
1204 | nextDate = start.addDays(weeksAhead*7 + weekday - 1); | 1203 | nextDate = start.addDays(weeksAhead*7 + weekday - 1); |
1205 | break; | 1204 | break; |
1206 | } | 1205 | } |
@@ -1215,7 +1214,7 @@ QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const | |||
1215 | // Check for the first later day in the current month | 1214 | // Check for the first later day in the current month |
1216 | if (!notThisMonth) | 1215 | if (!notThisMonth) |
1217 | nextDate = getFirstDateInMonth(earliestDate); | 1216 | nextDate = getFirstDateInMonth(earliestDate); |
1218 | if (!nextDate.isValid() && earliestDate.day() > 1) { | 1217 | if (!nextDate.isValid() ) { |
1219 | // Check for a day in the next scheduled month | 1218 | // Check for a day in the next scheduled month |
1220 | int months = startMonth - 1 + monthsAhead + rFreq; | 1219 | int months = startMonth - 1 + monthsAhead + rFreq; |
1221 | nextDate = getFirstDateInMonth(QDate(startYear + months/12, months%12 + 1, 1)); | 1220 | nextDate = getFirstDateInMonth(QDate(startYear + months/12, months%12 + 1, 1)); |
@@ -1272,7 +1271,7 @@ QDate Recurrence::getPreviousDateNoTime(const QDate &afterDate, bool *last) cons | |||
1272 | break; | 1271 | break; |
1273 | 1272 | ||
1274 | case rWeekly: { | 1273 | case rWeekly: { |
1275 | QDate start = dStart.addDays(1 - dStart.dayOfWeek()); // start of week for dStart | 1274 | QDate start = dStart.addDays(-((dStart.dayOfWeek() - rWeekStart + 7)%7)); // start of week for dStart |
1276 | int latestDayOfWeek = latestDate.dayOfWeek(); | 1275 | int latestDayOfWeek = latestDate.dayOfWeek(); |
1277 | int weeksAhead = start.daysTo(latestDate) / 7; | 1276 | int weeksAhead = start.daysTo(latestDate) / 7; |
1278 | int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week | 1277 | int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week |
@@ -1283,13 +1282,11 @@ QDate Recurrence::getPreviousDateNoTime(const QDate &afterDate, bool *last) cons | |||
1283 | weekday = getLastDayInWeek(latestDayOfWeek); | 1282 | weekday = getLastDayInWeek(latestDayOfWeek); |
1284 | // Check for a day in the previous scheduled week | 1283 | // Check for a day in the previous scheduled week |
1285 | if (!weekday) { | 1284 | if (!weekday) { |
1286 | int weekEnd = (rWeekStart + 5)%7 + 1; | ||
1287 | if (latestDayOfWeek < weekEnd) { | ||
1288 | if (!notThisWeek) | 1285 | if (!notThisWeek) |
1289 | weeksAhead -= rFreq; | 1286 | weeksAhead -= rFreq; |
1287 | int weekEnd = (rWeekStart + 5)%7 + 1; | ||
1290 | weekday = getLastDayInWeek(weekEnd); | 1288 | weekday = getLastDayInWeek(weekEnd); |
1291 | } | 1289 | } |
1292 | } | ||
1293 | if (weekday) | 1290 | if (weekday) |
1294 | prevDate = start.addDays(weeksAhead*7 + weekday - 1); | 1291 | prevDate = start.addDays(weeksAhead*7 + weekday - 1); |
1295 | break; | 1292 | break; |
@@ -3400,14 +3397,5 @@ QDate Recurrence::getLastDateInYear(const QDate &latestDate) const | |||
3400 | 3397 | ||
3401 | void Recurrence::dump() const | 3398 | void Recurrence::dump() const |
3402 | { | 3399 | { |
3403 | kdDebug() << "Recurrence::dump():" << endl; | 3400 | ; |
3404 | |||
3405 | kdDebug() << " type: " << recurs << endl; | ||
3406 | |||
3407 | kdDebug() << " rDays: " << endl; | ||
3408 | int i; | ||
3409 | for( i = 0; i < 7; ++i ) { | ||
3410 | kdDebug() << " " << i << ": " | ||
3411 | << ( rDays.testBit( i ) ? "true" : "false" ) << endl; | ||
3412 | } | ||
3413 | } | 3401 | } |