summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-11-20 11:15:05 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-11-23 09:41:16 +0000
commitc43f3f0c683841f7b2bd62ce8c1556f2e5412d4d (patch)
tree4ff669e937a01b4e7b18ced5f15bd9957020f817
parentdb18dbdcf13604ed165b944938da88e572462f87 (diff)
Fix broken daylight saving time check.
Change-Id: I9fd27cd014d3b1f13b176dc0d4e8af1a93c37ff5 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
-rw-r--r--src/libs/installer/lib7z_facade.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index cca05ea4c..3a544df51 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -323,6 +323,19 @@ static bool getFileTimeFromProperty(IInArchive* archive, int index, int propId,
return !IsFileTimeZero(ft);
}
+static bool IsDST(const QDateTime &datetime = QDateTime())
+{
+ const time_t seconds = static_cast<time_t>(datetime.isValid() ? datetime.toTime_t()
+ : QDateTime::currentDateTime().toTime_t());
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
+ struct tm t;
+ localtime_s(&t, &seconds);
+#else
+ const struct tm &t = *localtime(&seconds);
+#endif
+ return t.tm_isdst;
+}
+
static bool getDateTimeProperty(IInArchive *arc, int index, int id, QDateTime *value)
{
FILETIME ft7z;
@@ -342,6 +355,9 @@ static bool getDateTimeProperty(IInArchive *arc, int index, int id, QDateTime *v
}
*value = QDateTime(QDate(st.wYear, st.wMonth, st.wDay), QTime(st.wHour, st.wMinute,
st.wSecond));
+ const bool dst = IsDST();
+ if (dst != IsDST(*value))
+ *value = value->addSecs(dst ? -3600 : 3600);
return value->isValid();
}