diff --git a/autotests/testicalformat.h b/autotests/testicalformat.h --- a/autotests/testicalformat.h +++ b/autotests/testicalformat.h @@ -32,6 +32,7 @@ void testCharsets(); void testVolatileProperties(); void testCuType(); + void testAlarm(); }; #endif diff --git a/autotests/testicalformat.cpp b/autotests/testicalformat.cpp --- a/autotests/testicalformat.cpp +++ b/autotests/testicalformat.cpp @@ -150,3 +150,23 @@ QVERIFY(attendee2->name() == attendee->name()); QVERIFY(attendee2->email() == attendee->email()); } + +void ICalFormatTest::testAlarm() +{ + ICalFormat format; + + Event::Ptr event(new Event); + event->setDtStart(QDateTime(QDate(2017, 03, 24))); + Alarm::Ptr alarm = event->newAlarm(); + alarm->setType(Alarm::Display); + alarm->setStartOffset(Duration(0)); + + const QString serialized + = QLatin1String("BEGIN:VCALENDAR\nPRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN\nVERSION:2.0\n") + + format.toString(event.staticCast()) + + QLatin1String("\nEND:VCALENDAR"); + + Incidence::Ptr event2 = format.fromString(serialized); + Alarm::Ptr alarm2 = event2->alarms()[0]; + QCOMPARE(*alarm, *alarm2); +} diff --git a/src/icalformat_p.cpp b/src/icalformat_p.cpp --- a/src/icalformat_p.cpp +++ b/src/icalformat_p.cpp @@ -2644,7 +2644,7 @@ int seconds = d.hours * gSecondsPerHour; seconds += d.minutes * gSecondsPerMinute; seconds += d.seconds; - if (seconds) { + if (seconds || !days) { // Create second-type duration for 0 delay durations. seconds += days * gSecondsPerDay; if (d.is_neg) { seconds = -seconds;