summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2013-03-06 16:13:31 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-13 15:13:44 (GMT)
commitea2f597bb0be06ffd7353f6bc257e9d525039674 (patch)
tree1ddbcc8c8060358961a6c214c891a362a3bfa1bd /src
parentbaa9ec2b3f240fd0e4c5de025a9d9e023f2620a7 (diff)
downloadQt-ea2f597bb0be06ffd7353f6bc257e9d525039674.zip
Qt-ea2f597bb0be06ffd7353f6bc257e9d525039674.tar.gz
Qt-ea2f597bb0be06ffd7353f6bc257e9d525039674.tar.bz2
Workaround a bug in mktime on QNX
Under certain circumstances, mktime failes to convert the tm struct into secs since epoch. This is a workaround and fixes the qdatetime and qqmllocale autotests. Backport of: 56820382f26 Change-Id: I7d819aad2d6901cd096b441f2c18fd97108d9abb Reviewed-by: Mehdi Fekari <mfekari@rim.com> Reviewed-by: Wolfgang Bremer <wbremer@blackberry.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qdatetime.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 534b9ba..18a0c05 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -4116,6 +4116,16 @@ static void localToUtc(QDate &date, QTime &time, int isdst)
_tzset();
#endif
time_t secsSince1Jan1970UTC = mktime(&localTM);
+#ifdef Q_OS_QNX
+ //mktime sometimes fails on QNX. Following workaround converts the date and time then manually
+ if (secsSince1Jan1970UTC == (time_t)-1) {
+ QDateTime tempTime = QDateTime(date, time, Qt::UTC);;
+ tempTime = tempTime.addMSecs(timezone * 1000);
+ date = tempTime.date();
+ time = tempTime.time();
+ return;
+ }
+#endif
#endif
tm *brokenDown = 0;
#if defined(Q_OS_WINCE)