コード例 #1
0
void KSystemTimeZonesPrivate::setLocalZone()
{
    QString filename;
    if (m_localZoneName.startsWith(QLatin1Char('/'))) {
        // The time zone is specified by a file outside the zoneinfo directory
        filename = m_localZoneName;
    } else {
        // The zone name is either a known zone, or it's a relative file name
        // in zoneinfo directory which isn't in zone.tab.
        m_localZone = m_instance->zone(m_localZoneName);
        if (m_localZone.isValid())
            return;
        // It's a relative file name
        filename = m_zoneinfoDir + QLatin1Char('/') + m_localZoneName;
    }

    // Parse the specified time zone data file
    QString zonename = filename;
    if (zonename.startsWith(m_zoneinfoDir + QLatin1Char('/')))
        zonename = zonename.mid(m_zoneinfoDir.length() + 1);
    m_localZone = KTzfileTimeZone(KSystemTimeZonesPrivate::tzfileSource(), zonename);
    if (m_localZone.isValid() && m_instance)
    {
        // Add the new time zone to the list
        const KTimeZone oldzone = m_instance->zone(zonename);
        if (!oldzone.isValid() || oldzone.type() != "KTzfileTimeZone")
        {
            m_instance->remove(oldzone);
            m_instance->add(m_localZone);
        }
    }
}
コード例 #2
0
ファイル: ksystemtimezone.cpp プロジェクト: pvuorela/kcalcore
void KSystemTimeZonesPrivate::setLocalZone()
{
    if (m_localZoneName.startsWith('/'))
    {
        // The time zone is specified by a file outside the zoneinfo directory
        m_localZone = KTzfileTimeZone(KSystemTimeZonesPrivate::tzfileSource(), m_localZoneName);
        if (m_localZone.isValid() && m_instance)
        {
            // Add the new time zone to the list
            KTimeZone oldzone = m_instance->zone(m_localZoneName);
            if (!oldzone.isValid() || oldzone.type() != "KTzfileTimeZone")
            {
                m_instance->remove(oldzone);
                m_instance->add(m_localZone);
            }
        }
    }
    else
        m_localZone = m_instance->zone(m_localZoneName);
}