PDA

View Full Version : Adding 2 Dates



bwindorski
2nd December 2009, 23:14
Holla, is there an easy way to add 2 QTimes? Example I have a startTime and a travelTime. I manually set the start and travel times. What I need to do is dif(startTime, travelTime) and then add this returned time to the startTime. I know in .net its just one line....dateTime.addDateTime(dateTime) pretty simple. Any help would be greatly appreciated.

wysota
3rd December 2009, 01:00
QTime is probably not the best class to do it as it doesn't support wrapping but here goes:

QTime startTime = ..., travelTime = ...;
startTime.addMSecs(travelTime.msec());
One line here as well...

Tanuki-no Torigava
5th December 2009, 07:15
I used qPair to solve the same problem. Something like qMakePair(startTime, endTime) where startTime is either QDateTime or QTime