summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCesar Garcia Naranjo <cesarg9@gmail.com>2015-07-06 13:23:10 +0000
committerThiago Macieira <thiago.macieira@intel.com>2015-07-21 22:50:39 +0000
commit5c67ce5d6da11b8c4e445bba2a3ffb7b6e7f45d9 (patch)
treea560631109aac3817a9f05dd90f9e5ad9c82a25b /src
parent9072edb5f7f2b9f634fac5b5de7090e94ee491f7 (diff)
QTimeZone: Convert fractional timezones properly.
[ChangeLog][QtCore][QTimeZone] Fixed a wrong timezone conversion when the POSIX timezone rule contains a fractional timezone (e.g. VET4:30). Task-number: QTBUG-47037 Change-Id: I5d9052929bbcde174614ccf07c329264603e6431 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index 29f0e17012..35380b882a 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -389,12 +389,19 @@ static int parsePosixOffset(const QByteArray &timeRule)
// Format "[+|-]hh[:mm[:ss]]"
QList<QByteArray> parts = timeRule.split(':');
int count = parts.count();
- if (count == 3)
- return (parts.at(0).toInt() * -60 * 60) + (parts.at(1).toInt() * 60) + parts.at(2).toInt();
- else if (count == 2)
- return (parts.at(0).toInt() * -60 * 60) + (parts.at(1).toInt() * 60);
- else if (count == 1)
- return (parts.at(0).toInt() * -60 * 60);
+ if (count == 3) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * ((qAbs(hour) * 60 * 60) + (parts.at(1).toInt() * 60) + parts.at(2).toInt());
+ } else if (count == 2) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * ((qAbs(hour) * 60 * 60) + (parts.at(1).toInt() * 60));
+ } else if (count == 1) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * (qAbs(hour) * 60 * 60);
+ }
return 0;
}