[Bug 669087] Re: QDateTime addSecs() is behaving strangely with Qt 4.7.0
hakaishi
hakaishi at web.de
Sun Oct 31 14:03:30 UTC 2010
** Description changed:
- If adding less than 3*3600 secs everything is fine, but if it reaches three hours it adds one hour less. For examle adding 3 hours results in SomeTime+2 hours. You have to add 3600s to get the right time. Another Example: To get Time+4 hours you have to add 5 hours instead (only if you want to add 3 or more hours (>=3*3600 secs).
+ If adding less than 3*3600 secs everything is fine, but if it reaches three hours it adds one hour less. Note that this only occurs when adding to QDateTime SomeDateTime = dateEdit->dateTime(). For examle adding 3 hours results in SomeTime+2 hours. You have to add 3600s to get the right time. Another Example: To get Time+4 hours you have to add 5 hours instead (only if you want to add 3 or more hours (>=3*3600 secs).
+ An example code would look like this:
+
+ QDateTime nextDate = dateEdit->dateTime(); //the date is the current date
+ QDateTime timeInTheFuture = nextDate.addSecs(3*3600); //or (even if only one second) more than 3 hours
+ qDebug() << timeInTheFuture; //returns the current date and 2 hours
+
+
And there is anoter strange thing:
QDateTime thisTime = QDateTime::currentDateTime();
thisTime.addSecs(3600);
qDebug()<<thisTime;
This returns only the current time. addSecs(3600) seems to be ignored.
-
Kind regards
- Hakaishi
+ Hakaishi
--
QDateTime addSecs() is behaving strangely with Qt 4.7.0
https://bugs.launchpad.net/bugs/669087
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to qt4-x11 in ubuntu.
More information about the kubuntu-bugs
mailing list