Bug 344673 - [Regression] Invalid KDateTime after adding seconds to a valid datetime
Summary: [Regression] Invalid KDateTime after adding seconds to a valid datetime
Status: RESOLVED UNMAINTAINED
Alias: None
Product: frameworks-kdelibs4support
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Jarvie
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-28 17:31 UTC by Sergio Martins
Modified: 2021-07-30 18:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
testcase (1.00 KB, text/x-c++src)
2015-02-28 17:32 UTC, Sergio Martins
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Martins 2015-02-28 17:31:01 UTC
See attached test-case, after adding seconds to a valid KDateTime, the result is an invalid KDateTime, this is a regression from KDE4, and is causing a KCalCore test to fail

Reproducible: Always
Comment 1 Sergio Martins 2015-02-28 17:32:52 UTC
Created attachment 91344 [details]
testcase

output when running:
Valid? true "1998-03-01T00:00:00-05:00"
Last valid date "1998-03-29T00:40:00-05:00"
Comment 2 Sergio Martins 2015-04-10 18:29:42 UTC
Any chance you'll look at this David ?
Comment 3 David Jarvie 2015-04-10 20:15:09 UTC
I'm sorry, but I don't expect to build a KDE 5 development system any time soon, so I'm not in a position to investigate it.
Comment 4 Justin Zobel 2021-03-09 05:54:00 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 5 David Jarvie 2021-07-20 18:10:34 UTC
This bug still occurs. I'll have another look at it.
Comment 6 David Jarvie 2021-07-28 19:36:50 UTC
The bug is actually in KTimeZone::toZoneTime(), but I haven't identified exactly where yet.
Comment 7 David Jarvie 2021-07-30 18:44:17 UTC
BUG DIAGNOSIS

The date/time becomes invalid when in KTimeZone::toZoneTime(), the following line is executed (where 'dt' is a QDateTime instance):
    dt.setTimeSpec(Qt::LocalTime)

Running the test with the system time zone set to Europe/London, 'dt' is set invalid when before the call 'dt' is 1998-03-29 01:00:00.000 UTC. This is when the Europe/London summer time change occurred, so that 1998-03-29 01:00:00.000 Europe/London is invalid.

Rather than simply setting a flag to indicate that the local time zone should be used, QDateTime::setTimeSpec() evidently validates the resultant time against the current system time zone, even though the time is intended to be interpreted in a different time zone (America/New_York).


REQUIRED FIX

Fixing this bug would require significant changes to the KTimeZone and KDateTime classes. Given that, presumably, they will become obsolete in KDE 6, I don't think they are worth fixing.


RECOMMENDED ALTERNATIVE TO KDateTime

The class KADateTime in pim/kalarmcal is an updated version of KDateTime which uses Qt5 QDateTime time zone functionality instead of the much more limited Qt4 functionality used by KDateTime/KTimeZone. The issue does not exist in KADateTime, so KADateTime could be used as a substitute for KDateTime.