diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2019-03-21 14:58:03 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-06-23 14:01:12 +0200 |
commit | bcc3472aa231d0a65351b73ce9c75f7688be6623 (patch) | |
tree | ba9df3ea12ce93b9544a450a7e5c3a2bff1b92ea | |
parent | a04411119ead3d4473e4f0ac4bceedc585977b2f (diff) |
Add a warning and tidy some trivia
An attempt to setSpec(TimeZone) gets treated as setSpec(LocalTime), as
the method has no parameter to carry *which* zone; this was done
silently, but should be brought to the caller's attention. So warn.
Moved a declaration closer to its use, folded an if/else into a single
assignment using ?: and removed a fatuous \fn just before the function
it desribed.
Change-Id: Ia35c87e0ba373675d3ae1e6ef3bf05016c06c48d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index d85b76147b..183bc0f5ef 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2420,10 +2420,7 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat local.tm_mday = dd; local.tm_mon = mm - 1; local.tm_year = yy - 1900; - if (daylightStatus) - local.tm_isdst = int(*daylightStatus); - else - local.tm_isdst = -1; + local.tm_isdst = daylightStatus ? int(*daylightStatus) : -1; #if defined(Q_OS_WIN) int hh = local.tm_hour; @@ -2791,7 +2788,6 @@ static void refreshDateTime(QDateTimeData &d) const auto spec = extractSpec(status); const qint64 msecs = getMSecs(d); qint64 epochMSecs = 0; - int offsetFromUtc = 0; QDate testDate; QTime testTime; Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime); @@ -2828,6 +2824,7 @@ static void refreshDateTime(QDateTimeData &d) epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime); status = mergeDaylightStatus(status, dstStatus); } + int offsetFromUtc = 0; if (timeToMSecs(testDate, testTime) == msecs) { status |= QDateTimePrivate::ValidDateTime; // Cache the offset to use in offsetFromUtc() @@ -2883,7 +2880,7 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds) spec = Qt::UTC; break; case Qt::TimeZone: - // Use system time zone instead + qWarning("Using TimeZone in setTimeSpec() is unsupported"); // Use system time zone instead spec = Qt::LocalTime; Q_FALLTHROUGH(); case Qt::UTC: @@ -4260,8 +4257,6 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const } /*! - \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const - Returns a copy of this datetime converted to the given time \a spec. |