[Development] QDateTime addDays logic

Edward Welbourne edward.welbourne at qt.io
Thu Dec 13 20:57:48 CET 2018


>>> Not saying it's correct, just stating the fact that function name is
>>> confusing and potentially problematic because it doesn't do what it
>>> states it does.

Il 13/12/18 15:55, Edward Welbourne ha scritto:
>> Aye, there's plenty that isn't perfect, especially in old APIs.  None
>> the less, the Qt project makes strong backward-compatibility
>> promises; part of the price of that is that we don't lightly change
>> APIs, even when they aren't ideally named.

Giuseppe D'Angelo (13 December 2018 16:15) followed up with
> Probably part of the confusion is the fact that it's called "addDays",
> not "daysAdded" or something like that. In Qt, APIs that use the
> present imperative usually modify the object itself, while the ones in
> the past simple return a new modified object (e.g. QString::trimmed).

Indeed, the name plusDays might have been better.  With any luck we can
fix this in Qt6 by deprecating the old methods, supporting std::chrono
and just allowing arithmetic with appropriate std::chrono quantities, in
the obvious way.

	Eddy.



More information about the Development mailing list