Esempio n. 1
0
void DateTime::add(const Duration &duration) {
    if (isValid()) {
        DateTime x = addMSecs(duration.milliseconds());
        setDate( x.date() );
        setTime( x.time() );
        //kDebug(planDbg())<<toString();
    }
}
Esempio n. 2
0
void EstimateTester::scale() {
    StandardWorktime wt;
    QList<qint64> s = wt.scales();

    QCOMPARE( s.count(), 8 );

    Duration d = Estimate::scale( 1.0, Duration::Unit_Y, s );
    QCOMPARE( d.milliseconds(), s[0] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_Y, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_M, s );
    QCOMPARE( d.milliseconds(), s[1] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_M, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_w, s );
    QCOMPARE( d.milliseconds(), s[2] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_w, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_d, s );
    QCOMPARE( d.milliseconds(), s[3] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_d, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_h, s );
    QCOMPARE( d.milliseconds(), s[4] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_h, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_m, s );
    QCOMPARE( d.milliseconds(), s[5] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_m, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_s, s );
    QCOMPARE( d.milliseconds(), s[6] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_s, s ) );

    d = Estimate::scale( 1.0, Duration::Unit_ms, s );
    QCOMPARE( d.milliseconds(), s[7] );
    QCOMPARE( 1.0, Estimate::scale( d, Duration::Unit_ms, s ) );
}