summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-10-06 18:47:38 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2017-07-31 09:25:13 +0000
commit3d195c41e53847f7ec74a93f79e7a64d3581f8a8 (patch)
treea96b4575ffd53f56854ef23f5e668ab0beabc268 /src/corelib/tools
parent60a9747bb50934979ba66a3eeab6e5295fa2e492 (diff)
QTzTimeZonePrivate: resolve a misguided TODO
A three-way if/else-if/else had the same line of code as all three branches and a TODO to fix that. As it happens, the flags being tested here are irrelevant; they indicate whether the transition time (which is always given in UTC) was *specified* (i.e. the how a relevant authority identified the transition time) in terms of local wall-clock time, local standard time or UTC. The correction contemplated by TODO (and experimented with in an earlier version of this change, that broke correct tests) has in fact been done for us by the zoneinfo package's zic (zone-info compiler) in the course of writing the binary file we're parsing. These flags are only present in the binary file to enable the date command to correctly handle POSIX-style values for the TZ environment variable. We consequently have no need for the tz_ttisgmt or tz_ttisstd fields of our QTzType and can save the bother of recording them, when reading their part of the file. Change-Id: Ia33e87291ecc383eb5cb796d7b8a5213a94f1648 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index 1714c9802f..521475c2dd 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -134,8 +134,6 @@ struct QTzType {
int tz_gmtoff; // UTC offset in seconds
bool tz_isdst; // Is DST
quint8 tz_abbrind; // abbreviation list index
- bool tz_ttisgmt; // Is in UTC time
- bool tz_ttisstd; // Is in Standard time
};
Q_DECLARE_TYPEINFO(QTzType, Q_PRIMITIVE_TYPE);
@@ -234,9 +232,6 @@ static QVector<QTzType> parseTzTypes(QDataStream &ds, int tzh_typecnt)
// Parse Abbreviation Array Index, 1 byte
if (ds.status() == QDataStream::Ok)
ds >> type.tz_abbrind;
- // Set defaults in case not populated later
- type.tz_ttisgmt = false;
- type.tz_ttisstd = false;
if (ds.status() != QDataStream::Ok)
types.resize(i);
}
@@ -302,20 +297,24 @@ static QVector<QTzType> parseTzIndicators(QDataStream &ds, const QVector<QTzType
{
QVector<QTzType> result = types;
bool temp;
-
- // Parse tzh_ttisstdcnt x 1-byte standard/wall indicators
- for (int i = 0; i < tzh_ttisstdcnt && ds.status() == QDataStream::Ok; ++i) {
+ /*
+ Scan and discard indicators.
+
+ These indicators are only of use (by the date program) when "handling
+ POSIX-style time zone environment variables". The flags here say whether
+ the *specification* of the zone gave the time in UTC, local standard time
+ or local wall time; but whatever was specified has been digested for us,
+ already, by the zone-info compiler (zic), so that the tz_time values read
+ from the file (by parseTzTransitions) are all in UTC.
+ */
+
+ // Scan tzh_ttisstdcnt x 1-byte standard/wall indicators
+ for (int i = 0; i < tzh_ttisstdcnt && ds.status() == QDataStream::Ok; ++i)
ds >> temp;
- if (ds.status() == QDataStream::Ok)
- result[i].tz_ttisstd = temp;
- }
- // Parse tzh_ttisgmtcnt x 1-byte UTC/local indicators
- for (int i = 0; i < tzh_ttisgmtcnt && ds.status() == QDataStream::Ok; ++i) {
+ // Scan tzh_ttisgmtcnt x 1-byte UTC/local indicators
+ for (int i = 0; i < tzh_ttisgmtcnt && ds.status() == QDataStream::Ok; ++i)
ds >> temp;
- if (ds.status() == QDataStream::Ok)
- result[i].tz_ttisgmt = temp;
- }
return result;
}
@@ -790,14 +789,7 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
tran.ruleIndex = ruleIndex;
}
- // TODO convert to UTC if not in UTC
- if (tz_type.tz_ttisgmt)
- tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;
- else if (tz_type.tz_ttisstd)
- tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;
- else
- tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;
-
+ tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;
m_tranTimes.append(tran);
}