Changeset 489f262


Ignore:
Timestamp:
12/31/09 12:24:20 (13 years ago)
Author:
komarma <komarma@…>
Branches:
master, qt5
Children:
d0d0a66
Parents:
20a6010
Message:

Fixing datetime conversion

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/model/event.h

    r20a6010 r489f262  
    3131    int duration() const { return value("duration").toInt(); }
    3232    int activityId() const { return value("xid_activity").toInt(); }
    33     int typeId() const { return value("type").toInt(); }
    34     int languageId() const { return value("language").toInt(); }
     33    QString type() const { return value("type").toString(); }
     34    QString language() const { return value("language").toString(); }
    3535
    3636    void setId(int id) { setValue("id", id); }
     
    3939    void setDuration(int duration) { setValue("duration", duration); }
    4040    void setActivityId(int activityId) { setValue("xid_activity", activityId); }
    41     void setTypeId(int typeId) { setValue("type", typeId); }
    42     void setLanguageId(int languageId) { setValue("language", languageId); }
     41    void setType(const QString& type) { setValue("type", type); }
     42    void setLanguage(const QString& language) { setValue("language", language); }
    4343
    4444friend class EventTest;
  • src/orm/ormrecord.h

    r20a6010 r489f262  
    149149QVariant OrmRecord<T>::convertToC(QVariant value, QVariant::Type colType)
    150150{
    151     if (colType == QVariant::DateTime &&
    152         (value.type() == QVariant::UInt || value.type() == QVariant::Int))
     151    if (colType == QVariant::DateTime && value.canConvert<uint>())
    153152    {
    154153        QDateTime date;
     154        date.setTimeSpec(Qt::UTC);
    155155        date.setTime_t(value.toUInt());
    156156        return date;
  • src/test/model/eventtest.cpp

    r20a6010 r489f262  
    1919{
    2020    Event event = Event::getById(500, 1);
     21
    2122    QCOMPARE(event.id(), 500);
    22     QCOMPARE(event.start(), QDateTime::fromString("Sat Feb 7 11:30:00 2009"));
     23    QCOMPARE(event.start(), QDateTime(QDate(2009, 2, 7), QTime(11, 30, 0), Qt::UTC));
    2324    QCOMPARE(event.activityId(), 123);
    2425
    2526    // !!! TODO: typeId and languageId
    26     QCOMPARE(event.typeId(), 0);
    27     QCOMPARE(event.languageId(), 0);
     27    QCOMPARE(event.type(), QString("Podium"));
     28    QCOMPARE(event.language(), QString("English"));
    2829}
    2930
     
    3738    event.setDuration(30);
    3839    event.setActivityId(40);
    39     event.setTypeId(50);
    40     event.setLanguageId(60);
     40    event.setType(QString("type"));
     41    event.setLanguage(QString("language"));
    4142
    4243    QCOMPARE(event.id(), 10);
     
    4546    QCOMPARE(event.duration(), 30);
    4647    QCOMPARE(event.activityId(), 40);
    47     QCOMPARE(event.typeId(), 50);
    48     QCOMPARE(event.languageId(), 60);
     48    QCOMPARE(event.type(), QString("type"));
     49    QCOMPARE(event.language(), QString("language"));
    4950}
    50 
    5151
    5252void EventTest::hydrate()
Note: See TracChangeset for help on using the changeset viewer.