Commit 6701810f authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Kalendar now auto rounds new start dates for events to nearest 15 mins

parent 236501ee
Pipeline #102153 passed with stage
in 4 minutes and 50 seconds
......@@ -637,11 +637,19 @@ void IncidenceWrapper::triggerEditMode() // You edit a clone so that the origina
setIncidencePtr(clonedPtr);
}
static int nearestQuarterHour(int secsSinceEpoch)
{
const int quarterHourInSecs = 60 * 15;
return secsSinceEpoch + (quarterHourInSecs - secsSinceEpoch % quarterHourInSecs);
}
void IncidenceWrapper::setNewEvent()
{
auto event = KCalendarCore::Event::Ptr(new KCalendarCore::Event);
event->setDtStart(QDateTime::currentDateTime());
event->setDtEnd(QDateTime::currentDateTime().addSecs(60 * 60));
QDateTime start;
start.setSecsSinceEpoch(nearestQuarterHour(QDateTime::currentSecsSinceEpoch()));
event->setDtStart(start);
event->setDtEnd(start.addSecs(60 * 60));
Akonadi::Item incidenceItem;
incidenceItem.setPayload<KCalendarCore::Event::Ptr>(event);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment