[Kde-pim] Re: KCalCore::Calendar + adding time zones

David Jarvie djarvie at kde.org
Fri Apr 29 19:23:10 BST 2011


On Friday 29 April 2011 14:42:38 Patrick Ohly wrote:
> Hello!
> 
> I have a question about time zone definitions. Suppose that an
> application obtains a KTimeZone from KSystemTimeZones, then creates a
> new event with dtStart/End using that KTimeZone. Then it adds that event
> to a calendar:
> 
> void addEvent(const KCalCore::Calendar::Ptr &calendar)
> {
>     KSystemTimeZones zones;
>     KTimeZone berlin = m_zones.zone("Europe/Berlin");
>     ...
>     event = KCalCore::Event::Ptr(new KCalCore::Event);
>     KDateTime berlinstart(QDate(2011, 01, 01),
>                           QTime(15, 30, 0),
>                           KDateTime::Spec(berlin));
>     event->setDtStart(berlinstart);
>     ...
>     calendar->addEvent(event);
>     ...
>     ICalTimeZones *zones = calendar->timeZones();
>     zones->add(berlin); // does not work! berlin not a ICalTimeZone
> }
> 
> What about adding the time zone definition to the calendar's zone
> definitions? Is that something that the app must do or must not do?

The time zone definition should be added automatically when the calendar is written out - see ICalFormatImpl::writeEvent(), called by ICalFormat::toString(). The calendar's list of time zones is not updated except when it is read and written.

> Strictly speaking, the calendar should be self-contained, without
> depending on some external definitions. Following that logic, any time
> zone definitions used in the calendar must also be part of its
> definitions.
> 
> But the downside is that these events will forever use the calendar's
> copy of the time zone.
> 
> My observation is that the code works okay when the system definitions
> are not part of the calendar's definitions. The system definitions are
> used as fallback when not part of the calendar definitions.
> 
> But then why does icalformat_p.cpp's ICalFormatImpl::readICalDateTime()
> add system definitions to the calendar's tzlist? That seems inconsistent
> to me.

It only uses the system definition when the calendar doesn't contain a VTIMEZONE definition for the time zone.

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110429/02bb83d3/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list