| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | struct QTzTimeZone { | - | ||||||||||||||||||
| 16 | QLocale::Country country; | - | ||||||||||||||||||
| 17 | QByteArray comment; | - | ||||||||||||||||||
| 18 | }; | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash; | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | static QTzTimeZoneHash loadTzTimeZones() | - | ||||||||||||||||||
| 25 | { | - | ||||||||||||||||||
| 26 | QString path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/share/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/share/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 1 time by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 1 time by 1 test: }());return qstring_literal_temp;Executed by:
| 1 | ||||||||||||||||||
| 27 | if (!QFile::exists(path)
| 0-1 | ||||||||||||||||||
| 28 | path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/lib/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/lib/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }());return qstring_literal_temp;never executed: path = ([]() -> QString { enum { Size = sizeof(u"" "/usr/lib/zoneinfo/zone.tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/usr/lib/zoneinfo/zone.tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | 0 | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | QFile tzif(path); | - | ||||||||||||||||||
| 31 | if (!tzif.open(QIODevice::ReadOnly)
| 0-1 | ||||||||||||||||||
| 32 | return never executed: QTzTimeZoneHash();return QTzTimeZoneHash();never executed: return QTzTimeZoneHash(); | 0 | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | QTzTimeZoneHash zonesHash; | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | QTextStream ts(&tzif); | - | ||||||||||||||||||
| 37 | while (!ts.atEnd()
| 1-445 | ||||||||||||||||||
| 38 | const QString line = ts.readLine(); | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | if (!line.isEmpty()
| 0-445 | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | const auto parts = line.splitRef(QLatin1Char('\t')); | - | ||||||||||||||||||
| 43 | QTzTimeZone zone; | - | ||||||||||||||||||
| 44 | zone.country = QLocalePrivate::codeToCountry(parts.at(0)); | - | ||||||||||||||||||
| 45 | if (parts.size() > 3
| 204-217 | ||||||||||||||||||
| 46 | zone.comment = parts.at(3).toUtf8(); executed 204 times by 1 test: zone.comment = parts.at(3).toUtf8();Executed by:
| 204 | ||||||||||||||||||
| 47 | zonesHash.insert(parts.at(2).toUtf8(), zone); | - | ||||||||||||||||||
| 48 | } executed 421 times by 1 test: end of blockExecuted by:
| 421 | ||||||||||||||||||
| 49 | } executed 445 times by 1 test: end of blockExecuted by:
| 445 | ||||||||||||||||||
| 50 | return executed 1 time by 1 test: zonesHash;return zonesHash;Executed by:
executed 1 time by 1 test: return zonesHash;Executed by:
| 1 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | namespace { namespace Q_QGS_tzZones { typedef const QTzTimeZoneHash Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 1 time by 1 test: }guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 1 time by 1 test: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (loadTzTimeZones()))) : value (loadTzTimeZones()) { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blockExecuted by:
executed 1313 times by 1 test: &holder.value;return &holder.value;Executed by:
executed 1313 times by 1 test: } } } static QGlobalStatic<const QTzTimeZoneHash, Q_QGS_tzZones::innerFunction, Q_QGS_tzZones::guard> tzZones;;return &holder.value;Executed by:
| 0-1313 | ||||||||||||||||||
| 55 | struct QTzHeader { | - | ||||||||||||||||||
| 56 | char tzh_magic[4]; | - | ||||||||||||||||||
| 57 | char tzh_version; | - | ||||||||||||||||||
| 58 | char tzh_reserved[15]; | - | ||||||||||||||||||
| 59 | quint32 tzh_ttisgmtcnt; | - | ||||||||||||||||||
| 60 | quint32 tzh_ttisstdcnt; | - | ||||||||||||||||||
| 61 | quint32 tzh_leapcnt; | - | ||||||||||||||||||
| 62 | quint32 tzh_timecnt; | - | ||||||||||||||||||
| 63 | quint32 tzh_typecnt; | - | ||||||||||||||||||
| 64 | quint32 tzh_charcnt; | - | ||||||||||||||||||
| 65 | }; | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | struct QTzTransition { | - | ||||||||||||||||||
| 68 | qint64 tz_time; | - | ||||||||||||||||||
| 69 | quint8 tz_typeind; | - | ||||||||||||||||||
| 70 | }; | - | ||||||||||||||||||
| 71 | template<> class QTypeInfo<QTzTransition > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QTzTransition)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QTzTransition >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QTzTransition) }; static inline const char *name() { return "QTzTransition"; } }; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | struct QTzType { | - | ||||||||||||||||||
| 74 | int tz_gmtoff; | - | ||||||||||||||||||
| 75 | bool tz_isdst; | - | ||||||||||||||||||
| 76 | quint8 tz_abbrind; | - | ||||||||||||||||||
| 77 | bool tz_ttisgmt; | - | ||||||||||||||||||
| 78 | bool tz_ttisstd; | - | ||||||||||||||||||
| 79 | }; | - | ||||||||||||||||||
| 80 | template<> class QTypeInfo<QTzType > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QTzType)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QTzType >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QTzType) }; static inline const char *name() { return "QTzType"; } }; | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | static QTzHeader parseTzHeader(QDataStream &ds, bool *ok) | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | QTzHeader hdr; | - | ||||||||||||||||||
| 88 | quint8 ch; | - | ||||||||||||||||||
| 89 | *ok = false; | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | ds.readRawData(hdr.tzh_magic, 4); | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | if (memcmp(hdr.tzh_magic, "TZif", 4) != 0
| 0-908 | ||||||||||||||||||
| 95 | return never executed: hdr;return hdr;never executed: return hdr; | 0 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | ds >> ch; | - | ||||||||||||||||||
| 99 | hdr.tzh_version = ch; | - | ||||||||||||||||||
| 100 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
| 101 | || (hdr.tzh_version != '2'
| 0-894 | ||||||||||||||||||
| 102 | return never executed: hdr;return hdr;never executed: return hdr; | 0 | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | ds.readRawData(hdr.tzh_reserved, 15); | - | ||||||||||||||||||
| 107 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
| 108 | return never executed: hdr;return hdr;never executed: return hdr; | 0 | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | ds >> hdr.tzh_ttisgmtcnt >> hdr.tzh_ttisstdcnt >> hdr.tzh_leapcnt >> hdr.tzh_timecnt | - | ||||||||||||||||||
| 112 | >> hdr.tzh_typecnt >> hdr.tzh_charcnt; | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | if (ds.status() != QDataStream::Ok
| 0-908 | ||||||||||||||||||
| 116 | || hdr.tzh_timecnt > 1200
| 0-908 | ||||||||||||||||||
| 117 | || hdr.tzh_typecnt > 256
| 0-908 | ||||||||||||||||||
| 118 | || hdr.tzh_charcnt > 50
| 0-908 | ||||||||||||||||||
| 119 | || hdr.tzh_leapcnt > 50
| 0-908 | ||||||||||||||||||
| 120 | || hdr.tzh_ttisgmtcnt > hdr.tzh_typecnt
| 0-908 | ||||||||||||||||||
| 121 | || hdr.tzh_ttisstdcnt > hdr.tzh_typecnt
| 0-908 | ||||||||||||||||||
| 122 | return never executed: hdr;return hdr;never executed: return hdr; | 0 | ||||||||||||||||||
| 123 | } | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | *ok = true; | - | ||||||||||||||||||
| 126 | return executed 908 times by 2 tests: hdr;return hdr;Executed by:
executed 908 times by 2 tests: return hdr;Executed by:
| 908 | ||||||||||||||||||
| 127 | } | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | static QVector<QTzTransition> parseTzTransitions(QDataStream &ds, int tzh_timecnt, bool longTran) | - | ||||||||||||||||||
| 130 | { | - | ||||||||||||||||||
| 131 | QVector<QTzTransition> transitions(tzh_timecnt); | - | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | if (longTran
| 454 | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | for (int i = 0; i < tzh_timecnt
| 0-31553 | ||||||||||||||||||
| 136 | ds >> transitions[i].tz_time; | - | ||||||||||||||||||
| 137 | if (ds.status() != QDataStream::Ok
| 0-31553 | ||||||||||||||||||
| 138 | transitions.resize(i); never executed: transitions.resize(i); | 0 | ||||||||||||||||||
| 139 | } executed 31553 times by 2 tests: end of blockExecuted by:
| 31553 | ||||||||||||||||||
| 140 | } executed 454 times by 2 tests: else {end of blockExecuted by:
| 454 | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | int val; | - | ||||||||||||||||||
| 143 | for (int i = 0; i < tzh_timecnt
| 0-31278 | ||||||||||||||||||
| 144 | ds >> val; | - | ||||||||||||||||||
| 145 | transitions[i].tz_time = val; | - | ||||||||||||||||||
| 146 | if (ds.status() != QDataStream::Ok
| 0-31278 | ||||||||||||||||||
| 147 | transitions.resize(i); never executed: transitions.resize(i); | 0 | ||||||||||||||||||
| 148 | } executed 31278 times by 2 tests: end of blockExecuted by:
| 31278 | ||||||||||||||||||
| 149 | } executed 454 times by 2 tests: end of blockExecuted by:
| 454 | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | for (int i = 0; i < tzh_timecnt
| 0-62831 | ||||||||||||||||||
| 153 | quint8 typeind; | - | ||||||||||||||||||
| 154 | ds >> typeind; | - | ||||||||||||||||||
| 155 | if (ds.status() == QDataStream::Ok
| 0-62831 | ||||||||||||||||||
| 156 | transitions[i].tz_typeind = typeind; executed 62831 times by 2 tests: transitions[i].tz_typeind = typeind;Executed by:
| 62831 | ||||||||||||||||||
| 157 | } executed 62831 times by 2 tests: end of blockExecuted by:
| 62831 | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | return executed 908 times by 2 tests: transitions;return transitions;Executed by:
executed 908 times by 2 tests: return transitions;Executed by:
| 908 | ||||||||||||||||||
| 160 | } | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | static QVector<QTzType> parseTzTypes(QDataStream &ds, int tzh_typecnt) | - | ||||||||||||||||||
| 163 | { | - | ||||||||||||||||||
| 164 | QVector<QTzType> types(tzh_typecnt); | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | for (int i = 0; i < tzh_typecnt
| 0-5130 | ||||||||||||||||||
| 168 | QTzType &type = types[i]; | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | ds >> type.tz_gmtoff; | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
| 173 | ds >> type.tz_isdst; executed 5130 times by 2 tests: ds >> type.tz_isdst;Executed by:
| 5130 | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
| 176 | ds >> type.tz_abbrind; executed 5130 times by 2 tests: ds >> type.tz_abbrind;Executed by:
| 5130 | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | type.tz_ttisgmt = false; | - | ||||||||||||||||||
| 179 | type.tz_ttisstd = false; | - | ||||||||||||||||||
| 180 | if (ds.status() != QDataStream::Ok
| 0-5130 | ||||||||||||||||||
| 181 | types.resize(i); never executed: types.resize(i); | 0 | ||||||||||||||||||
| 182 | } executed 5130 times by 2 tests: end of blockExecuted by:
| 5130 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | return executed 908 times by 2 tests: types;return types;Executed by:
executed 908 times by 2 tests: return types;Executed by:
| 908 | ||||||||||||||||||
| 185 | } | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | static QMap<int, QByteArray> parseTzAbbreviations(QDataStream &ds, int tzh_charcnt, const QVector<QTzType> &types) | - | ||||||||||||||||||
| 188 | { | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | QMap<int, QByteArray> map; | - | ||||||||||||||||||
| 195 | quint8 ch; | - | ||||||||||||||||||
| 196 | QByteArray input; | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | for (int i = 0; i < tzh_charcnt
| 0-14643 | ||||||||||||||||||
| 199 | ds >> ch; | - | ||||||||||||||||||
| 200 | if (ds.status() == QDataStream::Ok
| 0-14643 | ||||||||||||||||||
| 201 | input.append(char(ch)); executed 14643 times by 2 tests: input.append(char(ch));Executed by:
| 14643 | ||||||||||||||||||
| 202 | else | - | ||||||||||||||||||
| 203 | return never executed: map;return map;never executed: return map; | 0 | ||||||||||||||||||
| 204 | } | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | for (const QTzType &type : types) { | - | ||||||||||||||||||
| 207 | QByteArray abbrev; | - | ||||||||||||||||||
| 208 | for (int i = type.tz_abbrind; input.at(i) != '\0'
| 5130-17454 | ||||||||||||||||||
| 209 | abbrev.append(input.at(i)); executed 17454 times by 2 tests: abbrev.append(input.at(i));Executed by:
| 17454 | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | map[type.tz_abbrind] = abbrev; | - | ||||||||||||||||||
| 212 | } executed 5130 times by 2 tests: end of blockExecuted by:
| 5130 | ||||||||||||||||||
| 213 | return executed 908 times by 2 tests: map;return map;Executed by:
executed 908 times by 2 tests: return map;Executed by:
| 908 | ||||||||||||||||||
| 214 | } | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | static void parseTzLeapSeconds(QDataStream &ds, int tzh_leapcnt, bool longTran) | - | ||||||||||||||||||
| 217 | { | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | qint64 val; | - | ||||||||||||||||||
| 221 | if (longTran
| 454 | ||||||||||||||||||
| 222 | qint64 time; | - | ||||||||||||||||||
| 223 | for (int i = 0; i < tzh_leapcnt
| 0-454 | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | ds >> time; | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | if (ds.status() == QDataStream::Ok
| 0 | ||||||||||||||||||
| 228 | ds >> val; never executed: ds >> val; | 0 | ||||||||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||||||||
| 230 | } executed 454 times by 2 tests: else {end of blockExecuted by:
| 454 | ||||||||||||||||||
| 231 | for (int i = 0; i < tzh_leapcnt
| 0-454 | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | ds >> val; | - | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | if (ds.status() == QDataStream::Ok
| 0 | ||||||||||||||||||
| 236 | ds >> val; never executed: ds >> val; | 0 | ||||||||||||||||||
| 237 | } never executed: end of block | 0 | ||||||||||||||||||
| 238 | } executed 454 times by 2 tests: end of blockExecuted by:
| 454 | ||||||||||||||||||
| 239 | } | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | static QVector<QTzType> parseTzIndicators(QDataStream &ds, const QVector<QTzType> &types, int tzh_ttisstdcnt, int tzh_ttisgmtcnt) | - | ||||||||||||||||||
| 242 | { | - | ||||||||||||||||||
| 243 | QVector<QTzType> result = types; | - | ||||||||||||||||||
| 244 | bool temp; | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | for (int i = 0; i < tzh_ttisstdcnt
| 0-5130 | ||||||||||||||||||
| 248 | ds >> temp; | - | ||||||||||||||||||
| 249 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
| 250 | result[i].tz_ttisstd = temp; executed 5130 times by 2 tests: result[i].tz_ttisstd = temp;Executed by:
| 5130 | ||||||||||||||||||
| 251 | } executed 5130 times by 2 tests: end of blockExecuted by:
| 5130 | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | for (int i = 0; i < tzh_ttisgmtcnt
| 0-5130 | ||||||||||||||||||
| 255 | ds >> temp; | - | ||||||||||||||||||
| 256 | if (ds.status() == QDataStream::Ok
| 0-5130 | ||||||||||||||||||
| 257 | result[i].tz_ttisgmt = temp; executed 5130 times by 2 tests: result[i].tz_ttisgmt = temp;Executed by:
| 5130 | ||||||||||||||||||
| 258 | } executed 5130 times by 2 tests: end of blockExecuted by:
| 5130 | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | return executed 908 times by 2 tests: result;return result;Executed by:
executed 908 times by 2 tests: return result;Executed by:
| 908 | ||||||||||||||||||
| 261 | } | - | ||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | static QByteArray parseTzPosixRule(QDataStream &ds) | - | ||||||||||||||||||
| 264 | { | - | ||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | QByteArray rule; | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | quint8 ch; | - | ||||||||||||||||||
| 269 | ds >> ch; | - | ||||||||||||||||||
| 270 | if (ch != '\n'
| 0-454 | ||||||||||||||||||
| 271 | return never executed: rule;return rule;never executed: return rule; | 0 | ||||||||||||||||||
| 272 | ds >> ch; | - | ||||||||||||||||||
| 273 | while (ch != '\n'
| 0-5987 | ||||||||||||||||||
| 274 | rule.append((char)ch); | - | ||||||||||||||||||
| 275 | ds >> ch; | - | ||||||||||||||||||
| 276 | } executed 5987 times by 2 tests: end of blockExecuted by:
| 5987 | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | return executed 454 times by 2 tests: rule;return rule;Executed by:
executed 454 times by 2 tests: return rule;Executed by:
| 454 | ||||||||||||||||||
| 279 | } | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | static QDate calculateDowDate(int year, int month, int dayOfWeek, int week) | - | ||||||||||||||||||
| 282 | { | - | ||||||||||||||||||
| 283 | QDate date(year, month, 1); | - | ||||||||||||||||||
| 284 | int startDow = date.dayOfWeek(); | - | ||||||||||||||||||
| 285 | if (startDow <= dayOfWeek
| 295-3471 | ||||||||||||||||||
| 286 | date = date.addDays(dayOfWeek - startDow - 7); executed 295 times by 2 tests: date = date.addDays(dayOfWeek - startDow - 7);Executed by:
| 295 | ||||||||||||||||||
| 287 | else | - | ||||||||||||||||||
| 288 | date = date.addDays(dayOfWeek - startDow); executed 3471 times by 2 tests: date = date.addDays(dayOfWeek - startDow);Executed by:
| 3471 | ||||||||||||||||||
| 289 | date = date.addDays(week * 7); | - | ||||||||||||||||||
| 290 | while (date.month() != month
| 1243-3766 | ||||||||||||||||||
| 291 | date = date.addDays(-7); executed 1243 times by 2 tests: date = date.addDays(-7);Executed by:
| 1243 | ||||||||||||||||||
| 292 | return executed 3766 times by 2 tests: date;return date;Executed by:
executed 3766 times by 2 tests: return date;Executed by:
| 3766 | ||||||||||||||||||
| 293 | } | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | static QDate calculatePosixDate(const QByteArray &dateRule, int year) | - | ||||||||||||||||||
| 296 | { | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | if (dateRule.at(0) == 'M'
| 24-3766 | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | QList<QByteArray> dateParts = dateRule.split('.'); | - | ||||||||||||||||||
| 301 | int month = dateParts.at(0).mid(1).toInt(); | - | ||||||||||||||||||
| 302 | int week = dateParts.at(1).toInt(); | - | ||||||||||||||||||
| 303 | int dow = dateParts.at(2).toInt(); | - | ||||||||||||||||||
| 304 | if (dow == 0
| 252-3514 | ||||||||||||||||||
| 305 | ++ executed 3514 times by 2 tests: dow;++dow;Executed by:
executed 3514 times by 2 tests: ++dow;Executed by:
| 3514 | ||||||||||||||||||
| 306 | return executed 3766 times by 2 tests: calculateDowDate(year, month, dow, week);return calculateDowDate(year, month, dow, week);Executed by:
executed 3766 times by 2 tests: return calculateDowDate(year, month, dow, week);Executed by:
| 3766 | ||||||||||||||||||
| 307 | } else if (dateRule.at(0) == 'J'
| 0-24 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | int doy = dateRule.mid(1).toInt(); | - | ||||||||||||||||||
| 310 | QDate date = QDate(year, 1, 1).addDays(doy - 1); | - | ||||||||||||||||||
| 311 | if (QDate::isLeapYear(date.year())
| 0-24 | ||||||||||||||||||
| 312 | date = date.addDays(-1); never executed: date = date.addDays(-1); | 0 | ||||||||||||||||||
| 313 | return executed 24 times by 1 test: date;return date;Executed by:
executed 24 times by 1 test: return date;Executed by:
| 24 | ||||||||||||||||||
| 314 | } else { | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | int doy = dateRule.toInt(); | - | ||||||||||||||||||
| 317 | return never executed: QDate(year, 1, 1).addDays(doy - 1);return QDate(year, 1, 1).addDays(doy - 1);never executed: return QDate(year, 1, 1).addDays(doy - 1); | 0 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | } | - | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | static int parsePosixTime(const char *begin, const char *end) | - | ||||||||||||||||||
| 323 | { | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | int hour, min = 0, sec = 0; | - | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | bool ok = false; | - | ||||||||||||||||||
| 334 | hour = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
| 335 | if (!ok
| 0-5037 | ||||||||||||||||||
| 336 | return executed 8 times by 1 test: (-2147483647 - 1);return (-2147483647 - 1);Executed by:
executed 8 times by 1 test: return (-2147483647 - 1);Executed by:
| 8 | ||||||||||||||||||
| 337 | if (begin < end
| 0-4855 | ||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | ++begin; | - | ||||||||||||||||||
| 340 | min = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
| 341 | if (!ok
| 0-174 | ||||||||||||||||||
| 342 | return never executed: (-2147483647 - 1);return (-2147483647 - 1);never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | if (begin < end
| 0-174 | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | ++begin; | - | ||||||||||||||||||
| 347 | sec = qstrtoll(begin, &begin, 10, &ok); | - | ||||||||||||||||||
| 348 | if (!ok
| 0 | ||||||||||||||||||
| 349 | return never executed: (-2147483647 - 1);return (-2147483647 - 1);never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||||||||
| 351 | } executed 174 times by 1 test: end of blockExecuted by:
| 174 | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | if (begin != end
| 0-5029 | ||||||||||||||||||
| 355 | return never executed: (-2147483647 - 1);return (-2147483647 - 1);never executed: return (-2147483647 - 1); | 0 | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | return executed 5029 times by 2 tests: (hour * 60 + min) * 60 + sec;return (hour * 60 + min) * 60 + sec;Executed by:
executed 5029 times by 2 tests: return (hour * 60 + min) * 60 + sec;Executed by:
| 5029 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | static QTime parsePosixTransitionTime(const QByteArray &timeRule) | - | ||||||||||||||||||
| 361 | { | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | int value = parsePosixTime(timeRule.constBegin(), timeRule.constEnd()); | - | ||||||||||||||||||
| 364 | if (value == (-2147483647 - 1)
| 8-504 | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | return executed 8 times by 1 test: QTime(2, 0, 0);return QTime(2, 0, 0);Executed by:
executed 8 times by 1 test: return QTime(2, 0, 0);Executed by:
| 8 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 | return executed 504 times by 2 tests: QTime::fromMSecsSinceStartOfDay(value * 1000);return QTime::fromMSecsSinceStartOfDay(value * 1000);Executed by:
executed 504 times by 2 tests: return QTime::fromMSecsSinceStartOfDay(value * 1000);Executed by:
| 504 | ||||||||||||||||||
| 369 | } | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | static int parsePosixOffset(const char *begin, const char *end) | - | ||||||||||||||||||
| 372 | { | - | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | bool negate = true; | - | ||||||||||||||||||
| 376 | if (*
| 0-4525 | ||||||||||||||||||
| 377 | ++begin; | - | ||||||||||||||||||
| 378 | } never executed: else if (*end of block
| 0-2621 | ||||||||||||||||||
| 379 | negate = false; | - | ||||||||||||||||||
| 380 | ++begin; | - | ||||||||||||||||||
| 381 | } executed 2621 times by 2 tests: end of blockExecuted by:
| 2621 | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | int value = parsePosixTime(begin, end); | - | ||||||||||||||||||
| 384 | if (value == (-2147483647 - 1)
| 0-4525 | ||||||||||||||||||
| 385 | return never executed: value;return value;never executed: return value; | 0 | ||||||||||||||||||
| 386 | return executed 4525 times by 2 tests: negate ? -value : value;return negate ? -value : value;Executed by:
executed 4525 times by 2 tests: return negate ? -value : value;Executed by:
| 4525 | ||||||||||||||||||
| 387 | } | - | ||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | static inline bool asciiIsLetter(char ch) | - | ||||||||||||||||||
| 390 | { | - | ||||||||||||||||||
| 391 | ch |= 0x20; | - | ||||||||||||||||||
| 392 | return executed 20587 times by 2 tests: ch >= 'a' && ch <= 'z';return ch >= 'a' && ch <= 'z';Executed by:
executed 20587 times by 2 tests: return ch >= 'a' && ch <= 'z';Executed by:
| 20587 | ||||||||||||||||||
| 393 | } | - | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | static QPair<QString, int> parsePosixZoneNameAndOffset(const char *&pos, const char *end) | - | ||||||||||||||||||
| 399 | { | - | ||||||||||||||||||
| 400 | static const char offsetChars[] = "0123456789:"; | - | ||||||||||||||||||
| 401 | QPair<QString, int> result = qMakePair(QString(), (-2147483647 - 1)); | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | const char *nameBegin = pos; | - | ||||||||||||||||||
| 404 | const char *nameEnd; | - | ||||||||||||||||||
| 405 | ((!(pos < end)) ? qt_assert("pos < end",__FILE__,465) : qt_noop()); | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | if (*
| 147-5002 | ||||||||||||||||||
| 408 | nameBegin = pos + 1; | - | ||||||||||||||||||
| 409 | nameEnd = nameBegin; | - | ||||||||||||||||||
| 410 | while (nameEnd < end
| 0-588 | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | ++nameEnd; | - | ||||||||||||||||||
| 413 | } executed 441 times by 1 test: end of blockExecuted by:
| 441 | ||||||||||||||||||
| 414 | pos = nameEnd + 1; | - | ||||||||||||||||||
| 415 | } executed 147 times by 1 test: else {end of blockExecuted by:
| 147 | ||||||||||||||||||
| 416 | nameBegin = pos; | - | ||||||||||||||||||
| 417 | nameEnd = nameBegin; | - | ||||||||||||||||||
| 418 | while (nameEnd < end
| 624-20587 | ||||||||||||||||||
| 419 | ++ executed 16209 times by 2 tests: nameEnd;++nameEnd;Executed by:
executed 16209 times by 2 tests: ++nameEnd;Executed by:
| 16209 | ||||||||||||||||||
| 420 | pos = nameEnd; | - | ||||||||||||||||||
| 421 | } executed 5002 times by 2 tests: end of blockExecuted by:
| 5002 | ||||||||||||||||||
| 422 | if (nameEnd - nameBegin < 3
| 0-5149 | ||||||||||||||||||
| 423 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | const char *zoneBegin = pos; | - | ||||||||||||||||||
| 427 | const char *zoneEnd = pos; | - | ||||||||||||||||||
| 428 | if (zoneEnd < end
| 0-4525 | ||||||||||||||||||
| 429 | ++ executed 2621 times by 2 tests: zoneEnd;++zoneEnd;Executed by:
executed 2621 times by 2 tests: ++zoneEnd;Executed by:
| 2621 | ||||||||||||||||||
| 430 | while (zoneEnd < end
| 4517-6295 | ||||||||||||||||||
| 431 | if (strchr(offsetChars, char(*zoneEnd)) == __null
| 632-5663 | ||||||||||||||||||
| 432 | break; executed 632 times by 2 tests: break;Executed by:
| 632 | ||||||||||||||||||
| 433 | ++zoneEnd; | - | ||||||||||||||||||
| 434 | } executed 5663 times by 2 tests: end of blockExecuted by:
| 5663 | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | result.first = QString::fromUtf8(nameBegin, nameEnd - nameBegin); | - | ||||||||||||||||||
| 437 | if (zoneEnd > zoneBegin
| 624-4525 | ||||||||||||||||||
| 438 | result.second = parsePosixOffset(zoneBegin, zoneEnd); executed 4525 times by 2 tests: result.second = parsePosixOffset(zoneBegin, zoneEnd);Executed by:
| 4525 | ||||||||||||||||||
| 439 | pos = zoneEnd; | - | ||||||||||||||||||
| 440 | return executed 5149 times by 2 tests: result;return result;Executed by:
executed 5149 times by 2 tests: return result;Executed by:
| 5149 | ||||||||||||||||||
| 441 | } | - | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | static QVector<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray &posixRule, | - | ||||||||||||||||||
| 444 | int startYear, int endYear, | - | ||||||||||||||||||
| 445 | int lastTranMSecs) | - | ||||||||||||||||||
| 446 | { | - | ||||||||||||||||||
| 447 | QVector<QTimeZonePrivate::Data> result; | - | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | - | |||||||||||||||||||
| 450 | if (startYear > 292278994
| 0-4517 | ||||||||||||||||||
| 451 | startYear = 292278994; never executed: startYear = 292278994; | 0 | ||||||||||||||||||
| 452 | if (endYear > 292278994
| 1-4516 | ||||||||||||||||||
| 453 | endYear = 292278994; executed 1 time by 1 test: endYear = 292278994;Executed by:
| 1 | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | QList<QByteArray> parts = posixRule.split(','); | - | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | QPair<QString, int> stdZone, dstZone; | - | ||||||||||||||||||
| 461 | { | - | ||||||||||||||||||
| 462 | const QByteArray &zoneinfo = parts.at(0); | - | ||||||||||||||||||
| 463 | const char *begin = zoneinfo.constBegin(); | - | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | stdZone = parsePosixZoneNameAndOffset(begin, zoneinfo.constEnd()); | - | ||||||||||||||||||
| 466 | if (stdZone.second == (-2147483647 - 1)
| 0-4517 | ||||||||||||||||||
| 467 | stdZone.second = 0; | - | ||||||||||||||||||
| 468 | } never executed: else if (begin < zoneinfo.constEnd()end of block
| 0-3885 | ||||||||||||||||||
| 469 | dstZone = parsePosixZoneNameAndOffset(begin, zoneinfo.constEnd()); | - | ||||||||||||||||||
| 470 | if (dstZone.second == (-2147483647 - 1)
| 8-624 | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | dstZone.second = stdZone.second + (60 * 60); | - | ||||||||||||||||||
| 473 | } executed 624 times by 2 tests: end of blockExecuted by:
| 624 | ||||||||||||||||||
| 474 | } executed 632 times by 2 tests: end of blockExecuted by:
| 632 | ||||||||||||||||||
| 475 | } | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | if (parts.count() == 1
| 632-3885 | ||||||||||||||||||
| 479 | QTimeZonePrivate::Data data; | - | ||||||||||||||||||
| 480 | data.atMSecsSinceEpoch = lastTranMSecs; | - | ||||||||||||||||||
| 481 | data.offsetFromUtc = stdZone.second; | - | ||||||||||||||||||
| 482 | data.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
| 483 | data.daylightTimeOffset = 0; | - | ||||||||||||||||||
| 484 | data.abbreviation = stdZone.first; | - | ||||||||||||||||||
| 485 | result << data; | - | ||||||||||||||||||
| 486 | return executed 3885 times by 2 tests: result;return result;Executed by:
executed 3885 times by 2 tests: return result;Executed by:
| 3885 | ||||||||||||||||||
| 487 | } | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | QList<QByteArray> dstParts = parts.at(1).split('/'); | - | ||||||||||||||||||
| 492 | QByteArray dstDateRule = dstParts.at(0); | - | ||||||||||||||||||
| 493 | QTime dstTime; | - | ||||||||||||||||||
| 494 | if (dstParts.count() > 1
| 172-460 | ||||||||||||||||||
| 495 | dstTime = parsePosixTransitionTime(dstParts.at(1)); executed 172 times by 1 test: dstTime = parsePosixTransitionTime(dstParts.at(1));Executed by:
| 172 | ||||||||||||||||||
| 496 | else | - | ||||||||||||||||||
| 497 | dstTime = QTime(2, 0, 0); executed 460 times by 2 tests: dstTime = QTime(2, 0, 0);Executed by:
| 460 | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | QList<QByteArray> stdParts = parts.at(2).split('/'); | - | ||||||||||||||||||
| 501 | QByteArray stdDateRule = stdParts.at(0); | - | ||||||||||||||||||
| 502 | QTime stdTime; | - | ||||||||||||||||||
| 503 | if (stdParts.count() > 1
| 292-340 | ||||||||||||||||||
| 504 | stdTime = parsePosixTransitionTime(stdParts.at(1)); executed 340 times by 2 tests: stdTime = parsePosixTransitionTime(stdParts.at(1));Executed by:
| 340 | ||||||||||||||||||
| 505 | else | - | ||||||||||||||||||
| 506 | stdTime = QTime(2, 0, 0); executed 292 times by 1 test: stdTime = QTime(2, 0, 0);Executed by:
| 292 | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | for (int year = startYear; year <= endYear
| 632-1895 | ||||||||||||||||||
| 509 | QTimeZonePrivate::Data dstData; | - | ||||||||||||||||||
| 510 | QDateTime dst(calculatePosixDate(dstDateRule, year), dstTime, Qt::UTC); | - | ||||||||||||||||||
| 511 | dstData.atMSecsSinceEpoch = dst.toMSecsSinceEpoch() - (stdZone.second * 1000); | - | ||||||||||||||||||
| 512 | dstData.offsetFromUtc = dstZone.second; | - | ||||||||||||||||||
| 513 | dstData.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
| 514 | dstData.daylightTimeOffset = dstZone.second - stdZone.second; | - | ||||||||||||||||||
| 515 | dstData.abbreviation = dstZone.first; | - | ||||||||||||||||||
| 516 | QTimeZonePrivate::Data stdData; | - | ||||||||||||||||||
| 517 | QDateTime std(calculatePosixDate(stdDateRule, year), stdTime, Qt::UTC); | - | ||||||||||||||||||
| 518 | stdData.atMSecsSinceEpoch = std.toMSecsSinceEpoch() - (dstZone.second * 1000); | - | ||||||||||||||||||
| 519 | stdData.offsetFromUtc = stdZone.second; | - | ||||||||||||||||||
| 520 | stdData.standardTimeOffset = stdZone.second; | - | ||||||||||||||||||
| 521 | stdData.daylightTimeOffset = 0; | - | ||||||||||||||||||
| 522 | stdData.abbreviation = stdZone.first; | - | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | if (year == 292278994
| 0-1894 | ||||||||||||||||||
| 525 | if (dstData.atMSecsSinceEpoch > 0
| 0-1 | ||||||||||||||||||
| 526 | result << dstData; | - | ||||||||||||||||||
| 527 | } executed 1 time by 1 test: else if (stdData.atMSecsSinceEpoch > 0end of blockExecuted by:
| 0-1 | ||||||||||||||||||
| 528 | result << stdData; | - | ||||||||||||||||||
| 529 | } never executed: end of block | 0 | ||||||||||||||||||
| 530 | } executed 1 time by 1 test: else if (dst < stdend of blockExecuted by:
| 1-1654 | ||||||||||||||||||
| 531 | result << dstData << stdData; | - | ||||||||||||||||||
| 532 | } executed 1654 times by 2 tests: else {end of blockExecuted by:
| 1654 | ||||||||||||||||||
| 533 | result << stdData << dstData; | - | ||||||||||||||||||
| 534 | } executed 240 times by 1 test: end of blockExecuted by:
| 240 | ||||||||||||||||||
| 535 | } | - | ||||||||||||||||||
| 536 | return executed 632 times by 2 tests: result;return result;Executed by:
executed 632 times by 2 tests: return result;Executed by:
| 632 | ||||||||||||||||||
| 537 | } | - | ||||||||||||||||||
| 538 | - | |||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | QTzTimeZonePrivate::QTzTimeZonePrivate() | - | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | : m_icu(0) | - | ||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | { | - | ||||||||||||||||||
| 545 | init(systemTimeZoneId()); | - | ||||||||||||||||||
| 546 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 547 | - | |||||||||||||||||||
| 548 | - | |||||||||||||||||||
| 549 | QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId) | - | ||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | : m_icu(0) | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | { | - | ||||||||||||||||||
| 554 | init(ianaId); | - | ||||||||||||||||||
| 555 | } executed 455 times by 2 tests: end of blockExecuted by:
| 455 | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | QTzTimeZonePrivate::QTzTimeZonePrivate(const QTzTimeZonePrivate &other) | - | ||||||||||||||||||
| 558 | : QTimeZonePrivate(other), m_tranTimes(other.m_tranTimes), | - | ||||||||||||||||||
| 559 | m_tranRules(other.m_tranRules), m_abbreviations(other.m_abbreviations), | - | ||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | m_icu(other.m_icu), | - | ||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | m_posixRule(other.m_posixRule) | - | ||||||||||||||||||
| 564 | { | - | ||||||||||||||||||
| 565 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | QTzTimeZonePrivate::~QTzTimeZonePrivate() | - | ||||||||||||||||||
| 568 | { | - | ||||||||||||||||||
| 569 | } | - | ||||||||||||||||||
| 570 | - | |||||||||||||||||||
| 571 | QTimeZonePrivate *QTzTimeZonePrivate::clone() | - | ||||||||||||||||||
| 572 | { | - | ||||||||||||||||||
| 573 | return executed 20 times by 1 test: new QTzTimeZonePrivate(*this);return new QTzTimeZonePrivate(*this);Executed by:
executed 20 times by 1 test: return new QTzTimeZonePrivate(*this);Executed by:
| 20 | ||||||||||||||||||
| 574 | } | - | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | void QTzTimeZonePrivate::init(const QByteArray &ianaId) | - | ||||||||||||||||||
| 577 | { | - | ||||||||||||||||||
| 578 | QFile tzif; | - | ||||||||||||||||||
| 579 | if (ianaId.isEmpty()
| 0-457 | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | tzif.setFileName(([]() -> QString { enum { Size = sizeof(u"" "/etc/localtime")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/localtime" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 582 | if (!tzif.open(QIODevice::ReadOnly)
| 0 | ||||||||||||||||||
| 583 | return; never executed: return; | 0 | ||||||||||||||||||
| 584 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId)); | - | ||||||||||||||||||
| 587 | if (!tzif.open(QIODevice::ReadOnly)
| 3-454 | ||||||||||||||||||
| 588 | tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId)); | - | ||||||||||||||||||
| 589 | if (!tzif.open(QIODevice::ReadOnly)
| 0-3 | ||||||||||||||||||
| 590 | return; executed 3 times by 2 tests: return;Executed by:
| 3 | ||||||||||||||||||
| 591 | } never executed: end of block | 0 | ||||||||||||||||||
| 592 | } executed 454 times by 2 tests: end of blockExecuted by:
| 454 | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | QDataStream ds(&tzif); | - | ||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | - | |||||||||||||||||||
| 597 | bool ok = false; | - | ||||||||||||||||||
| 598 | QTzHeader hdr = parseTzHeader(ds, &ok); | - | ||||||||||||||||||
| 599 | if (!ok
| 0-454 | ||||||||||||||||||
| 600 | return; never executed: return; | 0 | ||||||||||||||||||
| 601 | QVector<QTzTransition> tranList = parseTzTransitions(ds, hdr.tzh_timecnt, false); | - | ||||||||||||||||||
| 602 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 603 | return; never executed: return; | 0 | ||||||||||||||||||
| 604 | QVector<QTzType> typeList = parseTzTypes(ds, hdr.tzh_typecnt); | - | ||||||||||||||||||
| 605 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 606 | return; never executed: return; | 0 | ||||||||||||||||||
| 607 | QMap<int, QByteArray> abbrevMap = parseTzAbbreviations(ds, hdr.tzh_charcnt, typeList); | - | ||||||||||||||||||
| 608 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 609 | return; never executed: return; | 0 | ||||||||||||||||||
| 610 | parseTzLeapSeconds(ds, hdr.tzh_leapcnt, false); | - | ||||||||||||||||||
| 611 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 612 | return; never executed: return; | 0 | ||||||||||||||||||
| 613 | typeList = parseTzIndicators(ds, typeList, hdr.tzh_ttisstdcnt, hdr.tzh_ttisgmtcnt); | - | ||||||||||||||||||
| 614 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 615 | return; never executed: return; | 0 | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | if (hdr.tzh_version == '2'
| 0-447 | ||||||||||||||||||
| 619 | ok = false; | - | ||||||||||||||||||
| 620 | QTzHeader hdr2 = parseTzHeader(ds, &ok); | - | ||||||||||||||||||
| 621 | if (!ok
| 0-454 | ||||||||||||||||||
| 622 | return; never executed: return; | 0 | ||||||||||||||||||
| 623 | tranList = parseTzTransitions(ds, hdr2.tzh_timecnt, true); | - | ||||||||||||||||||
| 624 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 625 | return; never executed: return; | 0 | ||||||||||||||||||
| 626 | typeList = parseTzTypes(ds, hdr2.tzh_typecnt); | - | ||||||||||||||||||
| 627 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 628 | return; never executed: return; | 0 | ||||||||||||||||||
| 629 | abbrevMap = parseTzAbbreviations(ds, hdr2.tzh_charcnt, typeList); | - | ||||||||||||||||||
| 630 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 631 | return; never executed: return; | 0 | ||||||||||||||||||
| 632 | parseTzLeapSeconds(ds, hdr2.tzh_leapcnt, true); | - | ||||||||||||||||||
| 633 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 634 | return; never executed: return; | 0 | ||||||||||||||||||
| 635 | typeList = parseTzIndicators(ds, typeList, hdr2.tzh_ttisstdcnt, hdr2.tzh_ttisgmtcnt); | - | ||||||||||||||||||
| 636 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 637 | return; never executed: return; | 0 | ||||||||||||||||||
| 638 | m_posixRule = parseTzPosixRule(ds); | - | ||||||||||||||||||
| 639 | if (ds.status() != QDataStream::Ok
| 0-454 | ||||||||||||||||||
| 640 | return; never executed: return; | 0 | ||||||||||||||||||
| 641 | } executed 454 times by 2 tests: end of blockExecuted by:
| 454 | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | - | |||||||||||||||||||
| 646 | const int size = abbrevMap.size(); | - | ||||||||||||||||||
| 647 | m_abbreviations.clear(); | - | ||||||||||||||||||
| 648 | m_abbreviations.reserve(size); | - | ||||||||||||||||||
| 649 | QVector<int> abbrindList; | - | ||||||||||||||||||
| 650 | abbrindList.reserve(size); | - | ||||||||||||||||||
| 651 | for (auto it = abbrevMap.cbegin(), end = abbrevMap.cend(); it != end
| 454-1827 | ||||||||||||||||||
| 652 | m_abbreviations.append(it.value()); | - | ||||||||||||||||||
| 653 | abbrindList.append(it.key()); | - | ||||||||||||||||||
| 654 | } executed 1827 times by 2 tests: end of blockExecuted by:
| 1827 | ||||||||||||||||||
| 655 | for (int i = 0; i < typeList.size()
| 454-2700 | ||||||||||||||||||
| 656 | typeList[i].tz_abbrind = abbrindList.indexOf(typeList.at(i).tz_abbrind); executed 2700 times by 2 tests: typeList[i].tz_abbrind = abbrindList.indexOf(typeList.at(i).tz_abbrind);Executed by:
| 2700 | ||||||||||||||||||
| 657 | - | |||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | int utcOffset = 0; | - | ||||||||||||||||||
| 661 | for (const QTzTransition &tran : qAsConst(tranList)) { | - | ||||||||||||||||||
| 662 | if (!typeList.at(tran.tz_typeind).tz_isdst
| 3-454 | ||||||||||||||||||
| 663 | utcOffset = typeList.at(tran.tz_typeind).tz_gmtoff; | - | ||||||||||||||||||
| 664 | break; executed 454 times by 2 tests: break;Executed by:
| 454 | ||||||||||||||||||
| 665 | } | - | ||||||||||||||||||
| 666 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 667 | - | |||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | m_tranTimes.reserve(tranList.count()); | - | ||||||||||||||||||
| 670 | for (const QTzTransition &tz_tran : qAsConst(tranList)) { | - | ||||||||||||||||||
| 671 | QTzTransitionTime tran; | - | ||||||||||||||||||
| 672 | QTzTransitionRule rule; | - | ||||||||||||||||||
| 673 | const QTzType tz_type = typeList.at(tz_tran.tz_typeind); | - | ||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | if (!tz_type.tz_isdst
| 15309-16244 | ||||||||||||||||||
| 677 | utcOffset = tz_type.tz_gmtoff; executed 16244 times by 2 tests: utcOffset = tz_type.tz_gmtoff;Executed by:
| 16244 | ||||||||||||||||||
| 678 | rule.stdOffset = utcOffset; | - | ||||||||||||||||||
| 679 | rule.dstOffset = tz_type.tz_gmtoff - utcOffset; | - | ||||||||||||||||||
| 680 | rule.abbreviationIndex = tz_type.tz_abbrind; | - | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | int ruleIndex = m_tranRules.indexOf(rule); | - | ||||||||||||||||||
| 683 | if (ruleIndex == -1
| 1704-29849 | ||||||||||||||||||
| 684 | m_tranRules.append(rule); | - | ||||||||||||||||||
| 685 | tran.ruleIndex = m_tranRules.size() - 1; | - | ||||||||||||||||||
| 686 | } executed 1704 times by 2 tests: else {end of blockExecuted by:
| 1704 | ||||||||||||||||||
| 687 | tran.ruleIndex = ruleIndex; | - | ||||||||||||||||||
| 688 | } executed 29849 times by 2 tests: end of blockExecuted by:
| 29849 | ||||||||||||||||||
| 689 | - | |||||||||||||||||||
| 690 | - | |||||||||||||||||||
| 691 | if (tz_type.tz_ttisgmt
| 8759-22794 | ||||||||||||||||||
| 692 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 8759 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;Executed by:
| 8759 | ||||||||||||||||||
| 693 | else if (tz_type.tz_ttisstd
| 7286-15508 | ||||||||||||||||||
| 694 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 7286 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;Executed by:
| 7286 | ||||||||||||||||||
| 695 | else | - | ||||||||||||||||||
| 696 | tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; executed 15508 times by 2 tests: tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;Executed by:
| 15508 | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | m_tranTimes.append(tran); | - | ||||||||||||||||||
| 699 | } executed 31553 times by 2 tests: end of blockExecuted by:
| 31553 | ||||||||||||||||||
| 700 | - | |||||||||||||||||||
| 701 | if (ianaId.isEmpty()
| 0-454 | ||||||||||||||||||
| 702 | m_id = systemTimeZoneId(); never executed: m_id = systemTimeZoneId(); | 0 | ||||||||||||||||||
| 703 | else | - | ||||||||||||||||||
| 704 | m_id = ianaId; executed 454 times by 2 tests: m_id = ianaId;Executed by:
| 454 | ||||||||||||||||||
| 705 | } | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | QLocale::Country QTzTimeZonePrivate::country() const | - | ||||||||||||||||||
| 708 | { | - | ||||||||||||||||||
| 709 | return executed 422 times by 1 test: tzZones->value(m_id).country;return tzZones->value(m_id).country;Executed by:
executed 422 times by 1 test: return tzZones->value(m_id).country;Executed by:
| 422 | ||||||||||||||||||
| 710 | } | - | ||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | QString QTzTimeZonePrivate::comment() const | - | ||||||||||||||||||
| 713 | { | - | ||||||||||||||||||
| 714 | return executed 421 times by 1 test: QString::fromUtf8(tzZones->value(m_id).comment);return QString::fromUtf8(tzZones->value(m_id).comment);Executed by:
executed 421 times by 1 test: return QString::fromUtf8(tzZones->value(m_id).comment);Executed by:
| 421 | ||||||||||||||||||
| 715 | } | - | ||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch, | - | ||||||||||||||||||
| 718 | QTimeZone::NameType nameType, | - | ||||||||||||||||||
| 719 | const QLocale &locale) const | - | ||||||||||||||||||
| 720 | { | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | if (!m_icu
| 0-421 | ||||||||||||||||||
| 723 | m_icu = new QIcuTimeZonePrivate(m_id); executed 421 times by 1 test: m_icu = new QIcuTimeZonePrivate(m_id);Executed by:
| 421 | ||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | - | |||||||||||||||||||
| 726 | if (m_icu->isValid()
| 10-411 | ||||||||||||||||||
| 727 | return executed 411 times by 1 test: m_icu->displayName(atMSecsSinceEpoch, nameType, locale);return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);Executed by:
executed 411 times by 1 test: return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);Executed by:
| 411 | ||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | - | |||||||||||||||||||
| 732 | return executed 10 times by 1 test: abbreviation(atMSecsSinceEpoch);return abbreviation(atMSecsSinceEpoch);Executed by:
executed 10 times by 1 test: return abbreviation(atMSecsSinceEpoch);Executed by:
| 10 | ||||||||||||||||||
| 733 | } | - | ||||||||||||||||||
| 734 | - | |||||||||||||||||||
| 735 | QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType, | - | ||||||||||||||||||
| 736 | QTimeZone::NameType nameType, | - | ||||||||||||||||||
| 737 | const QLocale &locale) const | - | ||||||||||||||||||
| 738 | { | - | ||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | if (!m_icu
| 0-842 | ||||||||||||||||||
| 741 | m_icu = new QIcuTimeZonePrivate(m_id); never executed: m_icu = new QIcuTimeZonePrivate(m_id); | 0 | ||||||||||||||||||
| 742 | - | |||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | if (m_icu->isValid()
| 20-822 | ||||||||||||||||||
| 745 | return executed 822 times by 1 test: m_icu->displayName(timeType, nameType, locale);return m_icu->displayName(timeType, nameType, locale);Executed by:
executed 822 times by 1 test: return m_icu->displayName(timeType, nameType, locale);Executed by:
| 822 | ||||||||||||||||||
| 746 | - | |||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | - | |||||||||||||||||||
| 749 | - | |||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | - | |||||||||||||||||||
| 752 | - | |||||||||||||||||||
| 753 | if (timeType == QTimeZone::GenericTime
| 0-20 | ||||||||||||||||||
| 754 | timeType = QTimeZone::StandardTime; never executed: timeType = QTimeZone::StandardTime; | 0 | ||||||||||||||||||
| 755 | - | |||||||||||||||||||
| 756 | - | |||||||||||||||||||
| 757 | const qint64 currentMSecs = QDateTime::currentMSecsSinceEpoch(); | - | ||||||||||||||||||
| 758 | QTimeZonePrivate::Data tran = data(currentMSecs); | - | ||||||||||||||||||
| 759 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-20 | ||||||||||||||||||
| 760 | && ((timeType == QTimeZone::DaylightTime
| 1-10 | ||||||||||||||||||
| 761 | || (timeType == QTimeZone::StandardTime
| 1-10 | ||||||||||||||||||
| 762 | return executed 10 times by 1 test: tran.abbreviation;return tran.abbreviation;Executed by:
executed 10 times by 1 test: return tran.abbreviation;Executed by:
| 10 | ||||||||||||||||||
| 763 | } | - | ||||||||||||||||||
| 764 | - | |||||||||||||||||||
| 765 | - | |||||||||||||||||||
| 766 | tran = nextTransition(currentMSecs); | - | ||||||||||||||||||
| 767 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 1-9 | ||||||||||||||||||
| 768 | && ((timeType == QTimeZone::DaylightTime
| 0-1 | ||||||||||||||||||
| 769 | || (timeType == QTimeZone::StandardTime
| 0-1 | ||||||||||||||||||
| 770 | return executed 1 time by 1 test: tran.abbreviation;return tran.abbreviation;Executed by:
executed 1 time by 1 test: return tran.abbreviation;Executed by:
| 1 | ||||||||||||||||||
| 771 | } | - | ||||||||||||||||||
| 772 | - | |||||||||||||||||||
| 773 | - | |||||||||||||||||||
| 774 | tran = previousTransition(currentMSecs); | - | ||||||||||||||||||
| 775 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-9 | ||||||||||||||||||
| 776 | tran = previousTransition(tran.atMSecsSinceEpoch); executed 9 times by 1 test: tran = previousTransition(tran.atMSecsSinceEpoch);Executed by:
| 9 | ||||||||||||||||||
| 777 | if (tran.atMSecsSinceEpoch != invalidMSecs()
| 0-9 | ||||||||||||||||||
| 778 | && ((timeType == QTimeZone::DaylightTime
| 0-9 | ||||||||||||||||||
| 779 | || (timeType == QTimeZone::StandardTime
| 0-9 | ||||||||||||||||||
| 780 | return never executed: tran.abbreviation;return tran.abbreviation;never executed: return tran.abbreviation; | 0 | ||||||||||||||||||
| 781 | } | - | ||||||||||||||||||
| 782 | - | |||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | for (int i = m_tranTimes.size() - 1; i >= 0
| 1-41 | ||||||||||||||||||
| 785 | if (m_tranTimes.at(i).atMSecsSinceEpoch <= currentMSecs
| 0-41 | ||||||||||||||||||
| 786 | tran = dataForTzTransition(m_tranTimes.at(i)); | - | ||||||||||||||||||
| 787 | if ((timeType == QTimeZone::DaylightTime
| 0-41 | ||||||||||||||||||
| 788 | || (timeType == QTimeZone::StandardTime
| 0-33 | ||||||||||||||||||
| 789 | return executed 8 times by 1 test: tran.abbreviation;return tran.abbreviation;Executed by:
executed 8 times by 1 test: return tran.abbreviation;Executed by:
| 8 | ||||||||||||||||||
| 790 | } | - | ||||||||||||||||||
| 791 | } executed 33 times by 1 test: end of blockExecuted by:
| 33 | ||||||||||||||||||
| 792 | } executed 33 times by 1 test: end of blockExecuted by:
| 33 | ||||||||||||||||||
| 793 | - | |||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | return executed 1 time by 1 test: data(currentMSecs).abbreviation;return data(currentMSecs).abbreviation;Executed by:
executed 1 time by 1 test: return data(currentMSecs).abbreviation;Executed by:
| 1 | ||||||||||||||||||
| 796 | } | - | ||||||||||||||||||
| 797 | - | |||||||||||||||||||
| 798 | QString QTzTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
| 799 | { | - | ||||||||||||||||||
| 800 | return executed 860 times by 2 tests: data(atMSecsSinceEpoch).abbreviation;return data(atMSecsSinceEpoch).abbreviation;Executed by:
executed 860 times by 2 tests: return data(atMSecsSinceEpoch).abbreviation;Executed by:
| 860 | ||||||||||||||||||
| 801 | } | - | ||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | int QTzTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
| 804 | { | - | ||||||||||||||||||
| 805 | const QTimeZonePrivate::Data tran = data(atMSecsSinceEpoch); | - | ||||||||||||||||||
| 806 | return executed 441 times by 2 tests: tran.standardTimeOffset + tran.daylightTimeOffset;return tran.standardTimeOffset + tran.daylightTimeOffset;Executed by:
executed 441 times by 2 tests: return tran.standardTimeOffset + tran.daylightTimeOffset;Executed by:
| 441 | ||||||||||||||||||
| 807 | } | - | ||||||||||||||||||
| 808 | - | |||||||||||||||||||
| 809 | int QTzTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
| 810 | { | - | ||||||||||||||||||
| 811 | return executed 693 times by 2 tests: data(atMSecsSinceEpoch).standardTimeOffset;return data(atMSecsSinceEpoch).standardTimeOffset;Executed by:
executed 693 times by 2 tests: return data(atMSecsSinceEpoch).standardTimeOffset;Executed by:
| 693 | ||||||||||||||||||
| 812 | } | - | ||||||||||||||||||
| 813 | - | |||||||||||||||||||
| 814 | int QTzTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
| 815 | { | - | ||||||||||||||||||
| 816 | return executed 588 times by 2 tests: data(atMSecsSinceEpoch).daylightTimeOffset;return data(atMSecsSinceEpoch).daylightTimeOffset;Executed by:
executed 588 times by 2 tests: return data(atMSecsSinceEpoch).daylightTimeOffset;Executed by:
| 588 | ||||||||||||||||||
| 817 | } | - | ||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | bool QTzTimeZonePrivate::hasDaylightTime() const | - | ||||||||||||||||||
| 820 | { | - | ||||||||||||||||||
| 821 | - | |||||||||||||||||||
| 822 | for (const QTzTransitionRule &rule : m_tranRules) { | - | ||||||||||||||||||
| 823 | if (rule.dstOffset != 0
| 1519-3635 | ||||||||||||||||||
| 824 | return executed 1519 times by 2 tests: true;return true;Executed by:
executed 1519 times by 2 tests: return true;Executed by:
| 1519 | ||||||||||||||||||
| 825 | } executed 3635 times by 2 tests: end of blockExecuted by:
| 3635 | ||||||||||||||||||
| 826 | return executed 660 times by 1 test: false;return false;Executed by:
executed 660 times by 1 test: return false;Executed by:
| 660 | ||||||||||||||||||
| 827 | } | - | ||||||||||||||||||
| 828 | - | |||||||||||||||||||
| 829 | bool QTzTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const | - | ||||||||||||||||||
| 830 | { | - | ||||||||||||||||||
| 831 | return executed 295 times by 2 tests: (daylightTimeOffset(atMSecsSinceEpoch) != 0);return (daylightTimeOffset(atMSecsSinceEpoch) != 0);Executed by:
executed 295 times by 2 tests: return (daylightTimeOffset(atMSecsSinceEpoch) != 0);Executed by:
| 295 | ||||||||||||||||||
| 832 | } | - | ||||||||||||||||||
| 833 | - | |||||||||||||||||||
| 834 | QTimeZonePrivate::Data QTzTimeZonePrivate::dataForTzTransition(QTzTransitionTime tran) const | - | ||||||||||||||||||
| 835 | { | - | ||||||||||||||||||
| 836 | QTimeZonePrivate::Data data; | - | ||||||||||||||||||
| 837 | data.atMSecsSinceEpoch = tran.atMSecsSinceEpoch; | - | ||||||||||||||||||
| 838 | QTzTransitionRule rule = m_tranRules.at(tran.ruleIndex); | - | ||||||||||||||||||
| 839 | data.standardTimeOffset = rule.stdOffset; | - | ||||||||||||||||||
| 840 | data.daylightTimeOffset = rule.dstOffset; | - | ||||||||||||||||||
| 841 | data.offsetFromUtc = rule.stdOffset + rule.dstOffset; | - | ||||||||||||||||||
| 842 | data.abbreviation = QString::fromUtf8(m_abbreviations.at(rule.abbreviationIndex)); | - | ||||||||||||||||||
| 843 | return executed 9024 times by 2 tests: data;return data;Executed by:
executed 9024 times by 2 tests: return data;Executed by:
| 9024 | ||||||||||||||||||
| 844 | } | - | ||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const | - | ||||||||||||||||||
| 847 | { | - | ||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | if (m_tranTimes.size() > 0
| 0-3297 | ||||||||||||||||||
| 850 | && !m_posixRule.isEmpty()
| 0-2042 | ||||||||||||||||||
| 851 | const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
| 852 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
| 853 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
| 854 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
| 855 | for (int i = posixTrans.size() - 1; i >= 0
| 0-2059 | ||||||||||||||||||
| 856 | if (posixTrans.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch
| 17-2042 | ||||||||||||||||||
| 857 | QTimeZonePrivate::Data data = posixTrans.at(i); | - | ||||||||||||||||||
| 858 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
| 859 | return executed 2042 times by 2 tests: data;return data;Executed by:
executed 2042 times by 2 tests: return data;Executed by:
| 2042 | ||||||||||||||||||
| 860 | } | - | ||||||||||||||||||
| 861 | } executed 17 times by 2 tests: end of blockExecuted by:
| 17 | ||||||||||||||||||
| 862 | } never executed: end of block | 0 | ||||||||||||||||||
| 863 | - | |||||||||||||||||||
| 864 | - | |||||||||||||||||||
| 865 | for (int i = m_tranTimes.size() - 1; i >= 0
| 3-54031 | ||||||||||||||||||
| 866 | if (m_tranTimes.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch
| 1252-52779 | ||||||||||||||||||
| 867 | Data data = dataForTzTransition(m_tranTimes.at(i)); | - | ||||||||||||||||||
| 868 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
| 869 | return executed 1252 times by 2 tests: data;return data;Executed by:
executed 1252 times by 2 tests: return data;Executed by:
| 1252 | ||||||||||||||||||
| 870 | } | - | ||||||||||||||||||
| 871 | } executed 52779 times by 2 tests: end of blockExecuted by:
| 52779 | ||||||||||||||||||
| 872 | - | |||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | if (m_tranTimes.size() > 0
| 0-3 | ||||||||||||||||||
| 875 | Data data = dataForTzTransition(m_tranTimes.at(0)); | - | ||||||||||||||||||
| 876 | data.atMSecsSinceEpoch = forMSecsSinceEpoch; | - | ||||||||||||||||||
| 877 | return executed 3 times by 2 tests: data;return data;Executed by:
executed 3 times by 2 tests: return data;Executed by:
| 3 | ||||||||||||||||||
| 878 | } | - | ||||||||||||||||||
| 879 | - | |||||||||||||||||||
| 880 | - | |||||||||||||||||||
| 881 | return never executed: invalidData();return invalidData();never executed: return invalidData(); | 0 | ||||||||||||||||||
| 882 | } | - | ||||||||||||||||||
| 883 | - | |||||||||||||||||||
| 884 | bool QTzTimeZonePrivate::hasTransitions() const | - | ||||||||||||||||||
| 885 | { | - | ||||||||||||||||||
| 886 | return executed 5705 times by 2 tests: true;return true;Executed by:
executed 5705 times by 2 tests: return true;Executed by:
| 5705 | ||||||||||||||||||
| 887 | } | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const | - | ||||||||||||||||||
| 890 | { | - | ||||||||||||||||||
| 891 | - | |||||||||||||||||||
| 892 | if (m_tranTimes.size() > 0
| 0-8488 | ||||||||||||||||||
| 893 | && !m_posixRule.isEmpty()
| 0-1138 | ||||||||||||||||||
| 894 | const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
| 895 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
| 896 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
| 897 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
| 898 | for (int i = 0; i < posixTrans.size()
| 807-1905 | ||||||||||||||||||
| 899 | if (posixTrans.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch
| 313-1592 | ||||||||||||||||||
| 900 | return executed 313 times by 2 tests: posixTrans.at(i);return posixTrans.at(i);Executed by:
executed 313 times by 2 tests: return posixTrans.at(i);Executed by:
| 313 | ||||||||||||||||||
| 901 | } executed 1592 times by 2 tests: end of blockExecuted by:
| 1592 | ||||||||||||||||||
| 902 | } executed 807 times by 1 test: end of blockExecuted by:
| 807 | ||||||||||||||||||
| 903 | - | |||||||||||||||||||
| 904 | - | |||||||||||||||||||
| 905 | for (int i = 0; i < m_tranTimes.size()
| 1042-275638 | ||||||||||||||||||
| 906 | if (m_tranTimes.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch
| 7133-268505 | ||||||||||||||||||
| 907 | return executed 7133 times by 2 tests: dataForTzTransition(m_tranTimes.at(i));return dataForTzTransition(m_tranTimes.at(i));Executed by:
executed 7133 times by 2 tests: return dataForTzTransition(m_tranTimes.at(i));Executed by:
| 7133 | ||||||||||||||||||
| 908 | } | - | ||||||||||||||||||
| 909 | } executed 268505 times by 2 tests: end of blockExecuted by:
| 268505 | ||||||||||||||||||
| 910 | - | |||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | return executed 1042 times by 2 tests: invalidData();return invalidData();Executed by:
executed 1042 times by 2 tests: return invalidData();Executed by:
| 1042 | ||||||||||||||||||
| 913 | } | - | ||||||||||||||||||
| 914 | - | |||||||||||||||||||
| 915 | QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const | - | ||||||||||||||||||
| 916 | { | - | ||||||||||||||||||
| 917 | - | |||||||||||||||||||
| 918 | if (m_tranTimes.size() > 0
| 0-2796 | ||||||||||||||||||
| 919 | && !m_posixRule.isEmpty()
| 0-1355 | ||||||||||||||||||
| 920 | const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); | - | ||||||||||||||||||
| 921 | QVector<QTimeZonePrivate::Data> posixTrans = | - | ||||||||||||||||||
| 922 | calculatePosixTransitions(m_posixRule, year - 1, year + 1, | - | ||||||||||||||||||
| 923 | m_tranTimes.last().atMSecsSinceEpoch); | - | ||||||||||||||||||
| 924 | for (int i = posixTrans.size() - 1; i >= 0
| 0-2450 | ||||||||||||||||||
| 925 | if (posixTrans.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch
| 1095-1355 | ||||||||||||||||||
| 926 | return executed 1355 times by 2 tests: posixTrans.at(i);return posixTrans.at(i);Executed by:
executed 1355 times by 2 tests: return posixTrans.at(i);Executed by:
| 1355 | ||||||||||||||||||
| 927 | } executed 1095 times by 2 tests: end of blockExecuted by:
| 1095 | ||||||||||||||||||
| 928 | } never executed: end of block | 0 | ||||||||||||||||||
| 929 | - | |||||||||||||||||||
| 930 | - | |||||||||||||||||||
| 931 | for (int i = m_tranTimes.size() - 1; i >= 0
| 846-82123 | ||||||||||||||||||
| 932 | if (m_tranTimes.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch
| 595-81528 | ||||||||||||||||||
| 933 | return executed 595 times by 2 tests: dataForTzTransition(m_tranTimes.at(i));return dataForTzTransition(m_tranTimes.at(i));Executed by:
executed 595 times by 2 tests: return dataForTzTransition(m_tranTimes.at(i));Executed by:
| 595 | ||||||||||||||||||
| 934 | } | - | ||||||||||||||||||
| 935 | } executed 81528 times by 2 tests: end of blockExecuted by:
| 81528 | ||||||||||||||||||
| 936 | - | |||||||||||||||||||
| 937 | - | |||||||||||||||||||
| 938 | return executed 846 times by 2 tests: invalidData();return invalidData();Executed by:
executed 846 times by 2 tests: return invalidData();Executed by:
| 846 | ||||||||||||||||||
| 939 | } | - | ||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | - | |||||||||||||||||||
| 942 | QByteArray QTzTimeZonePrivate::systemTimeZoneId() const | - | ||||||||||||||||||
| 943 | { | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | QByteArray ianaId = qgetenv("TZ"); | - | ||||||||||||||||||
| 946 | if (!ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
| 947 | ianaId = ianaId.mid(1); never executed: ianaId = ianaId.mid(1); | 0 | ||||||||||||||||||
| 948 | - | |||||||||||||||||||
| 949 | - | |||||||||||||||||||
| 950 | - | |||||||||||||||||||
| 951 | - | |||||||||||||||||||
| 952 | - | |||||||||||||||||||
| 953 | if (ianaId == "/etc/localtime"
| 0-2 | ||||||||||||||||||
| 954 | ianaId.clear(); never executed: ianaId.clear(); | 0 | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | - | |||||||||||||||||||
| 957 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
| 958 | QFile tzif(([]() -> QString { enum { Size = sizeof(u"" "/etc/timezone")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/timezone" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 2 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 2 | ||||||||||||||||||
| 959 | if (tzif.open(QIODevice::ReadOnly)
| 0-2 | ||||||||||||||||||
| 960 | - | |||||||||||||||||||
| 961 | QTextStream ts(&tzif); | - | ||||||||||||||||||
| 962 | if (!ts.atEnd()
| 0-2 | ||||||||||||||||||
| 963 | ianaId = ts.readLine().toUtf8(); executed 2 times by 1 test: ianaId = ts.readLine().toUtf8();Executed by:
| 2 | ||||||||||||||||||
| 964 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 965 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 | - | |||||||||||||||||||
| 968 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
| 969 | const QString path = QFile::symLinkTarget(([]() -> QString { enum { Size = sizeof(u"" "/etc/localtime")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/localtime" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 970 | if (!path.isEmpty()
| 0 | ||||||||||||||||||
| 971 | - | |||||||||||||||||||
| 972 | int index = path.indexOf(QLatin1String("/zoneinfo/")) + 10; | - | ||||||||||||||||||
| 973 | ianaId = path.mid(index).toUtf8(); | - | ||||||||||||||||||
| 974 | } never executed: end of block | 0 | ||||||||||||||||||
| 975 | } never executed: end of block | 0 | ||||||||||||||||||
| 976 | - | |||||||||||||||||||
| 977 | - | |||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
| 980 | QFile tzif(([]() -> QString { enum { Size = sizeof(u"" "/etc/sysconfig/clock")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/etc/sysconfig/clock" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 981 | if (tzif.open(QIODevice::ReadOnly)
| 0 | ||||||||||||||||||
| 982 | - | |||||||||||||||||||
| 983 | QTextStream ts(&tzif); | - | ||||||||||||||||||
| 984 | QString line; | - | ||||||||||||||||||
| 985 | while (ianaId.isEmpty()
| 0 | ||||||||||||||||||
| 986 | line = ts.readLine(); | - | ||||||||||||||||||
| 987 | if (line.startsWith(QLatin1String("ZONE="))
| 0 | ||||||||||||||||||
| 988 | ianaId = line.mid(6, line.size() - 7).toUtf8(); | - | ||||||||||||||||||
| 989 | } never executed: else if (line.startsWith(QLatin1String("TIMEZONE="))end of block
| 0 | ||||||||||||||||||
| 990 | ianaId = line.mid(10, line.size() - 11).toUtf8(); | - | ||||||||||||||||||
| 991 | } never executed: end of block | 0 | ||||||||||||||||||
| 992 | } never executed: end of block | 0 | ||||||||||||||||||
| 993 | } never executed: end of block | 0 | ||||||||||||||||||
| 994 | } never executed: end of block | 0 | ||||||||||||||||||
| 995 | - | |||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | if (ianaId.isEmpty()
| 0-2 | ||||||||||||||||||
| 998 | ianaId = utcQByteArray(); never executed: ianaId = utcQByteArray(); | 0 | ||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | return executed 2 times by 1 test: ianaId;return ianaId;Executed by:
executed 2 times by 1 test: return ianaId;Executed by:
| 2 | ||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||
| 1002 | - | |||||||||||||||||||
| 1003 | QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const | - | ||||||||||||||||||
| 1004 | { | - | ||||||||||||||||||
| 1005 | QList<QByteArray> result = tzZones->keys(); | - | ||||||||||||||||||
| 1006 | std::sort(result.begin(), result.end()); | - | ||||||||||||||||||
| 1007 | return executed 468 times by 1 test: result;return result;Executed by:
executed 468 times by 1 test: return result;Executed by:
| 468 | ||||||||||||||||||
| 1008 | } | - | ||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const | - | ||||||||||||||||||
| 1011 | { | - | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | QList<QByteArray> result; | - | ||||||||||||||||||
| 1014 | for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end
| 1-421 | ||||||||||||||||||
| 1015 | if (it.value().country == country
| 29-392 | ||||||||||||||||||
| 1016 | result << it.key(); executed 29 times by 1 test: result << it.key();Executed by:
| 29 | ||||||||||||||||||
| 1017 | } executed 421 times by 1 test: end of blockExecuted by:
| 421 | ||||||||||||||||||
| 1018 | std::sort(result.begin(), result.end()); | - | ||||||||||||||||||
| 1019 | return executed 1 time by 1 test: result;return result;Executed by:
executed 1 time by 1 test: return result;Executed by:
| 1 | ||||||||||||||||||
| 1020 | } | - | ||||||||||||||||||
| 1021 | - | |||||||||||||||||||
| 1022 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |