summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-05-12 15:45:02 -0700
committerThiago Macieira <thiago.macieira@intel.com>2016-06-10 17:56:41 +0000
commit8e12120a2b3f033f07f609d5aa1f6089502a43a6 (patch)
tree3e074c4598007caf7d6a58cb39870275c71f5c1e /src
parentd3279b32173a37694a677055520f803d04d422bd (diff)
Simplify the QDateTimePrivate::setTimeSpec() function
Change-Id: I06bae9392f534e45b3f1ffff144df36cc98b5f3f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qdatetime.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 708526c8f3..1e91dccc81 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2513,31 +2513,26 @@ void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)
clearValidDateTime();
clearSetToDaylightStatus();
-#ifndef QT_BOOTSTRAPPED
- m_timeZone = QTimeZone();
-#endif // QT_BOOTSTRAPPED
-
switch (spec) {
case Qt::OffsetFromUTC:
- if (offsetSeconds == 0) {
- setSpec(Qt::UTC);
- m_offsetFromUtc = 0;
- } else {
- setSpec(Qt::OffsetFromUTC);
- m_offsetFromUtc = offsetSeconds;
- }
+ if (offsetSeconds == 0)
+ spec = Qt::UTC;
break;
case Qt::TimeZone:
// Use system time zone instead
- setSpec(Qt::LocalTime);
- m_offsetFromUtc = 0;
- break;
+ spec = Qt::LocalTime;
+ // fallthrough
case Qt::UTC:
case Qt::LocalTime:
- setSpec(spec);
- m_offsetFromUtc = 0;
+ offsetSeconds = 0;
break;
}
+
+ setSpec(spec);
+ m_offsetFromUtc = offsetSeconds;
+#ifndef QT_BOOTSTRAPPED
+ m_timeZone = QTimeZone();
+#endif // QT_BOOTSTRAPPED
}
void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)