Example #1
0
QDateTime GoogleCalHandler::parseDateTime(const QString &time, const QTimeZone &destZone)
{
    QDateTime result;
    // format year-month-dayThour:min:sec... we skip the rest, assuming is part of timezone.
    QTimeZone sourceZone = parseTimeZone(time);
    int year = time.mid(0,4).toInt();
    int month = time.mid(5,2).toInt();
    int day = time.mid(8,2).toInt();
    result.setDate(QDate(year, month, day));
    if (time.length() >= 19) {
        int hour = time.mid(11,2).toInt();
        int minute = time.mid(14,2).toInt();
        int second = time.mid(17,2).toInt();
        result.setTime(QTime(hour, minute, second));
    }
    if (destZone.isValid() && sourceZone.isValid())
        return destZone.convert(result, sourceZone);
    return result;
}
Example #2
0
static QDateTime fromTimeZone(const QDateTime &dt, const QTimeZone &timeZone)
{
    Q_ASSERT(dt.timeSpec() == Qt::LocalTime);
    QDateTime result(dt);
    if (timeZone.isValid()) {
        result.setTimeZone(timeZone);
        result = result.toLocalTime();
    }
    return result;
}
void
TimeDateModule::updateFields()
{
    if ( m_timeDate->canNtp() )
        ui->isNtpEnabledCheckBox->setChecked( m_timeDate->isNtpEnabled() );
    else
    {
        ui->isNtpEnabledCheckBox->setChecked( false );
        ui->isNtpEnabledCheckBox->setEnabled( false );
    }

    ui->isRtcLocalCheckBox->setChecked( m_timeDate->isRtcInLocalTimeZone() );

    QTimeZone timeZone = QTimeZone( m_timeZone.toLatin1() );
    if ( timeZone.isValid() )
    {
        ui->timeZoneLabel_2->setText( m_timeZone );
        ui->countryLabel_2->setText( QLocale::countryToString( timeZone.country() ) );

        QIcon yesIcon = QIcon();
        yesIcon.addFile( ":/images/yes.svg", QSize( 16, 16 ) );
        QIcon noIcon = QIcon();
        noIcon.addFile( ":/images/no.svg", QSize( 16, 16 ) );
        if ( timeZone.hasDaylightTime() )
            ui->hasDaylightTimeIcon->setPixmap( yesIcon.pixmap( QSize( 16, 16 ) ) );
        else
            ui->hasDaylightTimeIcon->setPixmap( noIcon.pixmap( QSize( 16, 16 ) ) );
        if ( timeZone.isDaylightTime( QDateTime::currentDateTime() ) )
            ui->isDaylightTimeIcon->setPixmap( yesIcon.pixmap( QSize( 16, 16 ) ) );
        else
            ui->isDaylightTimeIcon->setPixmap( noIcon.pixmap( QSize( 16, 16 ) ) );
        if ( timeZone.hasTransitions() )
            ui->hasTransitionsIcon->setPixmap( yesIcon.pixmap( QSize( 16, 16 ) ) );
        else
            ui->hasTransitionsIcon->setPixmap( noIcon.pixmap( QSize( 16, 16 ) ) );

        QTimeZone::OffsetData offset = timeZone.nextTransition( QDateTime::currentDateTime() );
        if ( offset.atUtc != QDateTime() )
        {
            ui->nextTransitionLabel->setEnabled( true );
            ui->nextTransitionTimeLabel->setEnabled( true );
            ui->nextTransitionTimeLabel->setText( offset.atUtc.toString( "dddd yyyy-MM-dd HH:mm:ss" ) );
        }
        else
        {
            ui->nextTransitionLabel->setEnabled( false );
            ui->nextTransitionTimeLabel->setEnabled( false );
            ui->nextTransitionTimeLabel->setText( tr( "none" ) );
        }
    }
}
Example #4
0
void Schedule::addEvent(const QDate& startDate,
                        const QTime& startTime,
                        const QString& subject,
                        const QString& location,
                        const QTimeZone& timeZone)
{
    Event event;
    event.subject = subject;
    event.location = location;
    event.startTime = QDateTime(startDate, startTime);

    if (timeZone.isValid())
        event.startTime.setTimeZone(timeZone);

    events_.insert(startDate, event);
}
Example #5
0
DateTime DateTime::fromString( const QString &dts, const QTimeZone &timeZone )
{
    if (dts.isEmpty()) {
        return DateTime();
    }
    QDateTime dt = QDateTime::fromString(dts, Qt::ISODate);
    if ( ! dt.isValid() ) {
        // try to parse in qt default format (used in early version)
        dt = QDateTime::fromString(dts, Qt::TextDate);
        if (timeZone.isValid()) {
            dt.setTimeZone(timeZone);
        }
        return DateTime(dt);
    }

    return DateTime(dt);
}
Example #6
0
/*!
    \internal
*/
void QWorldmapDialog::selected( const QTimeZone& zone )
{
    if (zone.isValid()) {
        mZone = zone;
    }
}
Example #7
0
DateTime::DateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone)
    : QDateTime( timeZone.isValid() ? QDateTime(date, time, timeZone).toLocalTime() : QDateTime(date, time, Qt::LocalTime) )
{
}
Example #8
0
QSXE_APP_KEY

#include "qtopiaserverapplication.h"

#include <QDesktopWidget>
#include <QLibraryInfo>

#include <sys/types.h>
#include <unistd.h>

#include <QValueSpaceItem>
#include <QKeyEvent>
#include <ThemedView>

// Not currently supported, available for demonstration purposes.
//#define QTOPIA_ANIMATED_SPLASH

static void refreshTimeZoneConfig()
{
   // We need to help WorldTime in setting up its configuration for
   //   the current translation
    // BEGIN no tr
    const char *defaultTz[] = {
        "America/New_York",
        "Asia/Beijing",
        "America/Los_Angeles",
        "Europe/London",
        "Asia/Tokyo",
        "Europe/Paris",
        0
    };

    // END no tr

    QTimeZone curZone;
    QString zoneID;
    int zoneIndex;
    QSettings cfg( "Trolltech", "WorldTime" );
    cfg.beginGroup( "TimeZones" );
    if (!cfg.contains( "Zone0" )){
        // We have no existing timezones - use the defaults that are untranslated strings
        QString currTz = QTimeZone::current().id();
        QStringList zoneDefaults;
        zoneDefaults.append( currTz );
        for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) {
            if ( defaultTz[i] != currTz )
                zoneDefaults.append( defaultTz[i] );
        }
        zoneIndex = 0;
        for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){
            cfg.setValue( "Zone" + QString::number( zoneIndex ) , *it);
            zoneIndex++;
        }
    }
    // We have an existing list of timezones - refresh the
    //  translations of QTimeZone name
    zoneIndex = 0;
    while (cfg.contains( "Zone"+ QString::number( zoneIndex ))){
        zoneID = cfg.value( "Zone" + QString::number( zoneIndex )).toString();
        curZone = QTimeZone( zoneID.toLatin1() );
        if ( !curZone.isValid() ){
            qWarning( "initEnvironment() Invalid QTimeZone %s", (const char *)zoneID.toLatin1() );
            break;
        }
        zoneIndex++;
    }

}