void QWinTimeZonePrivate::init(const QByteArray &ianaId) { if (ianaId.isEmpty()) { m_windowsId = windowsSystemZoneId(); m_id = systemTimeZoneId(); } else { m_windowsId = ianaIdToWindowsId(ianaId); m_id = ianaId; } if (!m_windowsId.isEmpty()) { // Open the base TZI for the time zone HKEY baseKey = NULL; const QString baseKeyPath = QString::fromUtf8(tzRegPath) + QLatin1Char('\\') + QString::fromUtf8(m_windowsId); if (openRegistryKey(baseKeyPath, &baseKey)) { // Load the localized names m_displayName = readRegistryString(baseKey, L"Display"); m_standardName = readRegistryString(baseKey, L"Std"); m_daylightName = readRegistryString(baseKey, L"Dlt"); // On Vista and later the optional dynamic key holds historic data const QString dynamicKeyPath = baseKeyPath + QStringLiteral("\\Dynamic DST"); HKEY dynamicKey = NULL; if (openRegistryKey(dynamicKeyPath, &dynamicKey)) { // Find out the start and end years stored, then iterate over them int startYear = readRegistryValue(dynamicKey, L"FirstEntry"); int endYear = readRegistryValue(dynamicKey, L"LastEntry"); for (int year = startYear; year <= endYear; ++year) { bool ruleOk; QWinTransitionRule rule = readRegistryRule(dynamicKey, (LPCWSTR)QString::number(year).utf16(), &ruleOk); rule.startYear = year; if (ruleOk) m_tranRules.append(rule); } RegCloseKey(dynamicKey); } else { // No dynamic data so use the base data bool ruleOk; QWinTransitionRule rule = readRegistryRule(baseKey, L"TZI", &ruleOk); rule.startYear = 1970; if (ruleOk) m_tranRules.append(rule); } RegCloseKey(baseKey); } } // If there are no rules then we failed to find a windowsId or any tzi info if (m_tranRules.size() == 0) { m_id.clear(); m_windowsId.clear(); m_displayName.clear(); } }
void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) { QJNIObjectPrivate jo_ianaId = QJNIObjectPrivate::fromString( QString::fromUtf8(ianaId) ); androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod( "java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;", static_cast<jstring>(jo_ianaId.object()) ); if (ianaId.isEmpty()) m_id = systemTimeZoneId(); else m_id = ianaId; }