From d2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 19 Feb 2005 10:19:59 +0000 Subject: duration fix --- (limited to 'libkcal/icalformatimpl.cpp') diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 2e38ae3..eae41aa 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -408,11 +408,11 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) // turned off as it always is set to PTS0 (and must not occur together with DTEND -// if (incidence->hasDuration()) { -// icaldurationtype duration; -// duration = writeICalDuration(incidence->duration()); -// icalcomponent_add_property(parent,icalproperty_new_duration(duration)); -// } + if (incidence->hasDuration()) { + icaldurationtype duration; + duration = writeICalDuration(incidence->duration()); + icalcomponent_add_property(parent,icalproperty_new_duration(duration)); + } } void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) @@ -1769,17 +1769,18 @@ icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) { icaldurationtype d; - d.weeks = seconds % gSecondsPerWeek; - seconds -= d.weeks * gSecondsPerWeek; - d.days = seconds % gSecondsPerDay; - seconds -= d.days * gSecondsPerDay; - d.hours = seconds % gSecondsPerHour; - seconds -= d.hours * gSecondsPerHour; - d.minutes = seconds % gSecondsPerMinute; - seconds -= d.minutes * gSecondsPerMinute; + d.is_neg = (seconds<0)?1:0; + if (seconds<0) seconds = -seconds; + + d.weeks = seconds / gSecondsPerWeek; + seconds %= gSecondsPerWeek; + d.days = seconds / gSecondsPerDay; + seconds %= gSecondsPerDay; + d.hours = seconds / gSecondsPerHour; + seconds %= gSecondsPerHour; + d.minutes = seconds / gSecondsPerMinute; + seconds %= gSecondsPerMinute; d.seconds = seconds; - d.is_neg = 0; - return d; } -- cgit v0.9.0.2