Replacement for KDateTime

David Jarvie djarvie at kde.org
Sun Aug 2 19:32:43 BST 2015


On Sunday 02 Aug 2015 14:26:18 John Layt wrote:
> On 1 August 2015 at 19:47, Sandro Knauß <bugs at sandroknauss.de> wrote:
> 
> > * dateOnly support is used a lot. In ICAL it differs if you set dateonly or
> > datetime. dateonly events f.ex. lasts a day without timezone info f.ex. "New
> > Year" is a dateonly event that lasts one day - it everywhere startsat 1.
> > january at 0:00 o'clock and ends at 24:00 o'clock  in your current timezome.
> > So it a different UTC time for every place at the world. That's why you can't
> > replace it with a datetime event, that needs a timezone, so it would be
> > wrongly displayed at other timezones.
> 
> I've been over this before on the PIM list, it's a fundamental mistake
> to say that 'Date Only' is an attribute of the datetime, it is in fact
> an attribute of the Event itself, and indeed is in the current API as
> such.  I fail to see why it needs to be in the datetime as well? If
> there is anywhere using the datetime property instead of the Event
> property it is doing it wrong, make it check the Event instead. Do not
> put it back in the datetime. Use the datetime to represent the valid
> start time or endtime of the all day event, i.e. 00:00 in the time
> zone of the datetime on which the event starts or finishes.

Date-only KDateTime instances are not only used for Event start/end timestamps. In KAlarm they are also used among other things for alarm snooze times (independently of whether the event is date-only or not). So usage of the date-only attribute is *not* restricted to Events (even if that is all it is used for in kcalcore).

Having a date-only attribute in KDateTime is very useful because it allows both date-time and date-only values to be encapsulated in a single class. This avoids having to be able to pass either a QDate or QDateTime or to have a separate flag everywhere this is used, and it allows date-time values to be compared to date-only values using class methods. Without this encapsulation, it would make a significant amount of code more cumbersome. KAlarm for one will certainly need the equivalent of KDateTime even if it has to have its own class, but given its use in kcalcore I think it should be available in a library. Also, do you know that date-only is NOT used elsewhere (apart from kcalcore and KAlarm)?

In order to use QDateTime in the representation of date-time or date-only values, the best solution in my opinion would be to have a new date time class which contains a QDateTime member together with a bool member indicating whether it is date-only. For a date-only value, the time component of the QDateTime should be set to 00:00:00, to avoid the problem of what an invalid value indicates.

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20150802/1b573b35/attachment.htm>


More information about the kde-core-devel mailing list