Skip to content

Commit

Permalink
[mkcal] Revert proper saving of dtEnd for alldays.
Browse files Browse the repository at this point in the history
This is mostly a revert of acf7c0e
to keep backward compatibility with already saved events
in database with dtEnd + 1.
  • Loading branch information
dcaliste committed May 25, 2020
1 parent 738d675 commit be0f1e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sqliteformat.cpp
Expand Up @@ -333,7 +333,13 @@ bool SqliteFormat::modifyComponents(const Incidence::Ptr &incidence, const QStri
if (incidence->type() == Incidence::TypeEvent) {
Event::Ptr event = incidence.staticCast<Event>();
if (event->hasEndDate()) {
effectiveDtEnd = event->dtEnd();
// Keep this one day addition for backward compatibility reasons
// with existing events in database.
if (incidence->allDay()) {
effectiveDtEnd = event->dtEnd().addDays(1);
} else {
effectiveDtEnd = event->dtEnd();
}
}
}
sqlite3_bind_date_time(d->mStorage, stmt1, index, effectiveDtEnd, incidence->allDay());
Expand Down Expand Up @@ -1201,6 +1207,13 @@ Incidence::Ptr SqliteFormat::selectComponents(sqlite3_stmt *stmt1, sqlite3_stmt
KDateTime end = getDateTime(d->mStorage, stmt1, 9, &endIsDate);
if (startIsDate && (!end.isValid() || endIsDate)) {
event->setAllDay(true);
// Keep backward compatibility with already saved events with end + 1.
if (end.isValid()) {
end = end.addDays(-1);
if (end == start) {
end = KDateTime();
}
}
}
if (end.isValid()) {
event->setDtEnd(end);
Expand Down

0 comments on commit be0f1e1

Please sign in to comment.