Replacement for KDateTime

Thiago Macieira thiago at kde.org
Tue Aug 4 03:09:52 BST 2015


On Monday 03 August 2015 22:00:04 John Layt wrote:
> On 3 August 2015 at 20:07, David Jarvie <djarvie at kde.org> wrote:
> > As I understand it, a QDateTime is invalid if either the date or time
> > component is invalid. People would usually expect that if
> > QDateTime::isValid() returns false, the object must be invalid. So a
> > date-only value in which only the date was valid would make the whole
> > object invalid, which is misleading and would almost certainly lead to
> > mistakes.
> That is correct and it is a long-standing QDateTime behaviour that I
> would hate to change in a non-major release due to the huge amount of
> code that expects it to work that way. It's just not an option to use.

QDateTime::isValid() indicates whether it's a valid date-time pair. It isn't. 
The QDateTime object may still contain a valid date or valid time though.

And I agree with John that we can't change it in 5.x and we probably won't 
change in 6.0 either because that would lead instead to code that assuming 
that a date-only QDateTime equals a full QDateTime at midnight. Or, worse, 
somehow parsing a time-only QDateTime as a few hours into Nov 24, -4713, which 
leads to severe issues when this time-only QDateTime somehow gets converted to 
time_t (out of range).

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358





More information about the kde-core-devel mailing list