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>
bb10
Edward Welbourne 2016-10-06 18:47:38 +02:00
parent 60a9747bb5
commit 3d195c41e5
1 changed files with 16 additions and 24 deletions

View File

@ -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;
/*
Scan and discard indicators.
// Parse 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;
}
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.
*/
// Parse tzh_ttisgmtcnt x 1-byte UTC/local indicators
for (int i = 0; i < tzh_ttisgmtcnt && ds.status() == QDataStream::Ok; ++i) {
// Scan tzh_ttisstdcnt x 1-byte standard/wall indicators
for (int i = 0; i < tzh_ttisstdcnt && ds.status() == QDataStream::Ok; ++i)
ds >> temp;
// 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);
}