当前位置: 首页>>代码示例>>C++>>正文


C++ QDateTime::addMSecs方法代码示例

本文整理汇总了C++中QDateTime::addMSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::addMSecs方法的具体用法?C++ QDateTime::addMSecs怎么用?C++ QDateTime::addMSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDateTime的用法示例。


在下文中一共展示了QDateTime::addMSecs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: formatEntry

static HistoryEntry formatEntry(QByteArray url, QByteArray title, qlonglong prdate)
{
    QDateTime dateTime = QDateTime::fromTime_t(prdate / 1000000);
    dateTime.addMSecs((prdate % 1000000) / 1000);
    HistoryEntry entry(url, dateTime, title);
    return entry;
}
开发者ID:porphyr,项目名称:arora,代码行数:7,代码来源:main.cpp

示例2: setMSecsSinceEpoch

/*
  Construct a QCa date time set to the same date/time as an EPICS time stamp
 */
QCaDateTime::QCaDateTime( unsigned long seconds, unsigned long nanoseconds )
{
    qint64 mSec;

    // First calculate mSecs and remaining nSecs
    // Down to the millisecond goes in the Qt base class structure,
    // the remaining nanoseconds are saved in this class
    //
    mSec = nanoseconds / 1000000;
    nSec = nanoseconds % 1000000;

#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0))
    // Calc number of mSecs since the epoc.
    // Note, although the EPICS time stamp is in seconds since a base, the method which
    // takes seconds since a base time uses a different base, so an offset is added.
    //
    qint64 mSecsSinceEpoch;
    mSecsSinceEpoch = ((qint64) (seconds + EPICSQtEpocOffset)) * 1000 + mSec;
    setMSecsSinceEpoch (mSecsSinceEpoch);
#else
    // setMSecsSinceEpoch does not exist in older versions.
    //
    QDateTime temp;
    temp.setTime_t( seconds + EPICSQtEpocOffset );
    *this = temp.addMSecs (mSec);
#endif
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:30,代码来源:QCaDateTime.cpp

示例3:

void CAdBlock::setScte35StartTime(QDateTime firstAdStartTime)
{
  if (!m_adConfigs.empty())
  {
    CAdConfig firstAd = m_adConfigs.front();
    startB2bTimer(firstAdStartTime.addMSecs(QTime().msecsTo(firstAd.getTotalDuration())));
  }
}
开发者ID:ElJeffe,项目名称:AdServerSimulator,代码行数:8,代码来源:channelconfig.cpp

示例4: sampleToDate

QDateTime DataFile::sampleToDate(int sample)
{
	int timeOffset = round(sample/getSamplingFrequency()*1000);

	QDateTime date = getStartDate();
	date = date.addMSecs(timeOffset);

	return date;
}
开发者ID:hejtmy,项目名称:ZSBS,代码行数:9,代码来源:datafile.cpp

示例5: timeSteps

//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart)
{
    if (!ecl_file) return;

    CVF_ASSERT(timeSteps && daysSinceSimulationStart);

    timeSteps->clear();
    daysSinceSimulationStart->clear();

    // Get the number of occurrences of the INTEHEAD keyword
    int numINTEHEAD = ecl_file_get_num_named_kw(ecl_file, INTEHEAD_KW);
    
    // Get the number of occurrences of the DOUBHEAD keyword
    int numDOUBHEAD = ecl_file_get_num_named_kw(ecl_file, DOUBHEAD_KW);

    std::vector<double> dayValues(numINTEHEAD, 0.0); // Init fraction to zero

    // Read out fraction of day if number of keywords are identical
    if (numINTEHEAD == numDOUBHEAD)
    {
        for (int i = 0; i < numDOUBHEAD; i++)
        {
            ecl_kw_type* kwDOUBHEAD = ecl_file_iget_named_kw(ecl_file, DOUBHEAD_KW, i);
            if (kwDOUBHEAD)
            {
                dayValues[i] = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
            }
        }
    }

    std::set<QDateTime> existingTimesteps;

    for (int i = 0; i < numINTEHEAD; i++)
    {
        ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, i);
        CVF_ASSERT(kwINTEHEAD);
        int day = 0;
        int month = 0;
        int year = 0;
        getDayMonthYear(kwINTEHEAD, &day, &month, &year);

        QDateTime reportDateTime = RiaQDateTimeTools::createUtcDateTime(QDate(year, month, day));
        CVF_ASSERT(reportDateTime.isValid());

        double dayValue = dayValues[i];
        double dayFraction = dayValue - cvf::Math::floor(dayValue);
        double milliseconds = dayFraction * 24.0 * 60.0 * 60.0 * 1000.0;

        reportDateTime = reportDateTime.addMSecs(milliseconds);
        if (existingTimesteps.insert(reportDateTime).second)
        {
            timeSteps->push_back(reportDateTime);
            daysSinceSimulationStart->push_back(dayValue);
        }
    }
}
开发者ID:OPM,项目名称:ResInsight,代码行数:59,代码来源:RifEclipseOutputFileTools.cpp

示例6: TEST

  TEST(Time, Verify_46_Hack)
  {
    qint64 MSecsPerDay = 86400000;
    QDateTime epoch = QDateTime::fromString("1970-01-01T00:00:00.000", Qt::ISODate);
    epoch.setTimeSpec(Qt::UTC);

    Time &time = Time::GetInstance();
    time.UseRealTime();

    QDateTime now = time.CurrentTime();
    QDateTime now_46 = QDateTime::currentDateTime().toUTC();

    EXPECT_EQ(now_46.date(), now.date());
    EXPECT_TRUE(qAbs(now_46.time().msecsTo(now.time())) < 100);

    qint64 msecs = time.MSecsSinceEpoch();
    now = QDateTime::currentDateTime().toUTC();
    int days_46 = epoch.date().daysTo(now.date());
    int msecs_46 = epoch.time().msecsTo(now.time());
    qint64 total_msecs_46 = (days_46 * MSecsPerDay) + msecs_46;

    EXPECT_TRUE(qAbs(msecs - total_msecs_46) < 100);

    time.UseVirtualTime();

    now = time.CurrentTime();
    now_46 = epoch.addMSecs(time.MSecsSinceEpoch());
    EXPECT_EQ(now, now_46);

    for(int i = 0; i < 50; i++) {
      time.IncrementVirtualClock(Random::GetInstance().GetInt());
      now = time.CurrentTime();
      now_46 = epoch.addMSecs(time.MSecsSinceEpoch());
      EXPECT_EQ(now, now_46);
    }
  }
开发者ID:ASchurman,项目名称:Dissent,代码行数:36,代码来源:TimeTest.cpp

示例7: addData

    void MapLogPlacemarkData::addData(const GeoObjectID &id, SinglePointDataPtr data)
    {
        if (!mData.contains(id))
        {
            QVector<SinglePointDataPtr> newHistory;
            newHistory.push_back(data);
            mData.insert(id, newHistory);
            return;
        }

        if (data->isCritical())
        {
            insert(id, data);
        }

        SinglePointDataPtr mostRecent = mData[id].last();

        QDateTime lastTime = mostRecent->time();
        QDateTime recently = lastTime.addMSecs(mostRecent->durationMs());
        QDateTime now = QDateTime::currentDateTime();
        qint64 timespan = recently.daysTo(now) * msecsInDay + recently.time().msecsTo(now.time());

        if (*data == *mostRecent)
        {   //ignore, but advance duration
            //qDebug("Data didn't change");
            mostRecent->advanceDurationMs(timespan);
            return;
        }

        if (timespan > mTimeResolution)
        {
            //qDebug("Data changed and fits in resolution, inserting");
            insert(id, data);
        }
        else
        {
            //qDebug("Data discarded");
            if (mExtraDataBehavior == MapLogPlacemarkData::Ignore)
            { //ignore data completely
                return;
            }
            else
            { //TODO compress data somehow (for now also ignore)
                return;
            }
        }
    }
开发者ID:mlepicka,项目名称:robotic-map,代码行数:47,代码来源:MapLogPlacemarkData.cpp

示例8: onLoadHistory

void ChatForm::onLoadHistory()
{
    LoadHistoryDialog dlg;

    if (dlg.exec())
    {
        QDateTime fromTime = dlg.getFromDate();
        QDateTime toTime = QDateTime::currentDateTime();

        if (fromTime > toTime)
            return;

        if (earliestMessage)
        {
            if (*earliestMessage < fromTime)
                return;
            if (*earliestMessage < toTime)
            {
                toTime = *earliestMessage;
                toTime = toTime.addMSecs(-1);
            }
        }

        auto msgs = HistoryKeeper::getInstance()->getChatHistory(HistoryKeeper::ctSingle, f->userId, fromTime, toTime);

        ToxID storedPrevId;
        std::swap(storedPrevId, previousId);
        QList<ChatActionPtr> historyMessages;

        for (const auto &it : msgs)
        {
            ChatActionPtr ca = genMessageActionAction(ToxID::fromString(it.sender), it.message, false, it.timestamp.toLocalTime());
            historyMessages.append(ca);
        }
        std::swap(storedPrevId, previousId);

        int savedSliderPos = chatWidget->verticalScrollBar()->maximum() - chatWidget->verticalScrollBar()->value();

        if (earliestMessage != nullptr)
            *earliestMessage = fromTime;

        chatWidget->insertMessagesTop(historyMessages);

        savedSliderPos = chatWidget->verticalScrollBar()->maximum() - savedSliderPos;
        chatWidget->verticalScrollBar()->setValue(savedSliderPos);
    }
}
开发者ID:D3cryptor,项目名称:qTox,代码行数:47,代码来源:chatform.cpp

示例9: datetimeFromNumber

QDateTime datetimeFromNumber(double num, bool is1904)
{
    if (!is1904 && num > 60)
        num = num - 1;

    qint64 msecs = static_cast<qint64>(num * 1000*60*60*24.0 + 0.5);
    QDateTime epoch(is1904 ? QDate(1904, 1, 1): QDate(1899, 12, 31), QTime(0,0));

    QDateTime dt = epoch.addMSecs(msecs);

#if QT_VERSION >= 0x050200
    // Remove one hour to see whether the date is Daylight
    QDateTime dt2 = dt.addMSecs(-3600);
    if (dt2.isDaylightTime())
        return dt2;
#endif

    return dt;
}
开发者ID:BlackNib,项目名称:QtXlsxWriter,代码行数:19,代码来源:xlsxutility.cpp

示例10: timerTimeout

void MarbleClockPrivate::timerTimeout()
{
    // calculate real period elapsed since last call
    QDateTime curenttime( QDateTime::currentDateTimeUtc() );
    int msecdelta = m_lasttime.msecsTo( curenttime );
    m_lasttime = curenttime;

    // update m_datetime at m_speed pace
    m_datetime = m_datetime.addMSecs( msecdelta * m_speed );

    // trigger round minute update (at m_speed pace)
    emit q->timeChanged();

    // sleeptime is the time to sleep until next round minute, at m_speed pace
    int sleeptime = ( m_updateInterval * 1000 - (qreal)(m_datetime.time().msec() + m_datetime.time().second() * 1000 ) ) / m_speed;
    if ( sleeptime < 1000 ) {
        // don't trigger more often than 1s
        sleeptime = 1000;
    }
    m_timer.start( sleeptime );

    //mDebug() << "MarbleClock: will sleep for " << sleeptime;
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:23,代码来源:MarbleClock.cpp

示例11: sendNotifications_Reminders

void Calendar::sendNotifications_Reminders()
{
    QDateTime now = QDateTime::currentDateTime();
    now = now.addSecs(-now.time().second());
    now = now.addMSecs(-now.time().msec());

    // Get the list of reminders that are dated at this minute and
    // erase them from reminder storage
    QList<Appointment> reminders;
    engageBufferLock("accessing/updating reminders list");
    QMap<QDateTime, Appointment>::iterator it = _aptCache->reminders()->find(now);

    // Collect all reminders dated to now
    while (it != _aptCache->reminders()->end() && it.key() == now) {
        reminders.push_back(*it);
        it = _aptCache->reminders()->erase(it);
    }
    releaseBufferLock("finished accessing reminders list");

    // Broadcast new reminders to observers
    if (reminders.count() > 0)
        emit newReminders(this, reminders);
}
开发者ID:anjinkristou,项目名称:AptNotifier,代码行数:23,代码来源:calendar.cpp

示例12: QQuickView

//-----------------------------------------------------------------------------
MainView::MainView( ) :
    QQuickView( ),
    _propertiesList( new qan::PropertiesList( this ) )
{
    // Dynamic exemple code ------------
    Properties* p1 = new qan::Properties( this );

    p1->addProperty( "intProperty", QVariant::fromValue< int >( 40 ) );
    qDebug( ) << *p1;
    qDebug( ) << "--";
    QDateTime current = QDateTime::currentDateTimeUtc( );
    p1->setProperty( "intProperty", current, 41 );
    p1->setProperty( "intProperty", current.addMSecs( 1000 ), 42 );
    qDebug( ) << *p1;
    qDebug( ) << "--";
    //-----------------------------------

    // Static exemple code ------------
    MyProperties* mp = new MyProperties( this );
    qDebug( ) << *mp;
    //-----------------------------------

    Properties* p = new Properties( this );
    p->setObjectName( "MyQanProperties" );

    generateRandTimeValues< int >( *p, "intProperty", 15, 15000 ); // Generate random int value over 15s int the "int property"intProperty'
    p->addProperty( "intProperty", QVariant::fromValue< int >( 40 ) );
    qDebug( ) << *p;

    rootContext( )->setContextProperty( "qanPropertiesModel", p->getPropertiesModel( )  );
    rootContext( )->setContextProperty( "qanProperties", p );
    qan::PropertyGraphModel* graphModel = p->getPropertyGraphModel( "intProperty" );
    rootContext( )->setContextProperty( "qanPropertyGraphModel", graphModel );

    setSource( QUrl::fromLocalFile( "main.qml" ) );
}
开发者ID:vishnucool220,项目名称:QuickQanava,代码行数:37,代码来源:qanMainWindow.cpp

示例13: dateTime

/*!
    \fn Convert::dateTime(const QString& mSeconds)
 */
QDateTime Convert::dateTime(const QString& mSeconds) {
    static QDateTime zeroTime(QDate(1970,1,1), QTime(0,0), Qt::UTC);
    return zeroTime.addMSecs(mSeconds.toULongLong());
}
开发者ID:BackupTheBerlios,项目名称:juicer-svn,代码行数:7,代码来源:convert.cpp

示例14: loadHistory

void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
{
    QDateTime now = historyBaselineDate.addMSecs(-1);

    if (since > now)
        return;

    if (!earliestMessage.isNull())
    {
        if (earliestMessage < since)
            return;

        if (earliestMessage < now)
        {
            now = earliestMessage;
            now = now.addMSecs(-1);
        }
    }

    auto msgs = HistoryKeeper::getInstance()->getChatHistory(HistoryKeeper::ctSingle, f->getToxID().publicKey, since, now);

    ToxId storedPrevId = previousId;
    ToxId prevId;

    QList<ChatLine::Ptr> historyMessages;

    QDate lastDate(1,0,0);
    for (const auto &it : msgs)
    {
        // Show the date every new day
        QDateTime msgDateTime = it.timestamp.toLocalTime();
        QDate msgDate = msgDateTime.date();

        if (msgDate > lastDate)
        {
            lastDate = msgDate;
            historyMessages.append(ChatMessage::createChatInfoMessage(msgDate.toString(Settings::getInstance().getDateFormat()), ChatMessage::INFO, QDateTime()));
        }

        // Show each messages
        ToxId authorId = ToxId(it.sender);
        QString authorStr = authorId.isActiveProfile() ? Core::getInstance()->getUsername() : resolveToxID(authorId);
        bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive);

        ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr,
                                                              isAction ? it.message.right(it.message.length() - 4) : it.message,
                                                              isAction ? ChatMessage::ACTION : ChatMessage::NORMAL,
                                                              authorId.isActiveProfile(),
                                                              QDateTime());

        if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
            msg->hideSender();

        prevId = authorId;
        prevMsgDateTime = msgDateTime;

        if (it.isSent || !authorId.isActiveProfile())
        {
            msg->markAsSent(msgDateTime);
        }
        else
        {
            if (processUndelivered)
            {
                int rec;
                if (!isAction)
                    rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
                else
                    rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());

                getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
            }
        }
        historyMessages.append(msg);
    }

    previousId = storedPrevId;
    int savedSliderPos = chatWidget->verticalScrollBar()->maximum() - chatWidget->verticalScrollBar()->value();

    earliestMessage = since;

    chatWidget->insertChatlineOnTop(historyMessages);

    savedSliderPos = chatWidget->verticalScrollBar()->maximum() - savedSliderPos;
    chatWidget->verticalScrollBar()->setValue(savedSliderPos);
}
开发者ID:stqism,项目名称:qTox,代码行数:86,代码来源:chatform.cpp

示例15: readFiles

void ConfigurationParser::readFiles(DataLayer *layer)
{
    Q_ASSERT(isStartElement()
             && name() == "files");
    
    QDateTime startDate;
    int start = 0;
    QDateTime endDate;
    int end = 0;
    int digits = 0;
    QString scheme;
    int skip = 0;
    
    while(!atEnd()) {
        readNext();
        
        if(isEndElement()) {
            break;
        }
        
        if(isStartElement()) {
            if(name() == "start") {
                QXmlStreamAttributes att = attributes();
                startDate.setTime(QTime::fromString(att.value("time").toString(), Qt::ISODate));
                startDate.setDate(QDate::fromString(att.value("date").toString(), Qt::ISODate));
                start = readCharacters().toInt();
            }
            else if(name() == "end") {
                QXmlStreamAttributes att = attributes();
                endDate.setTime(QTime::fromString(att.value("time").toString(), Qt::ISODate));
                endDate.setDate(QDate::fromString(att.value("date").toString(), Qt::ISODate));
                end = readCharacters().toInt();
            }
            else if(name() == "scheme") {
                QXmlStreamAttributes att = attributes();
                digits = att.value("digits").toString().toInt();
                if(att.hasAttribute("skip")) {
                    skip = att.value("skip").toString().toInt();
                }
                scheme = readCharacters();
            }
            else {
                readUnknownElement();
            }
        }
    }
    
    if(startDate.isValid() && endDate.isValid()) {
        qint64 spanMSecs = endDate.toMSecsSinceEpoch() - startDate.toMSecsSinceEpoch();
        int count = end - start;
        qint64 diffMSecs = spanMSecs / count;
        
        for(int i = start; i < end; i += 1 + skip) {
            QDateTime fileTime = startDate.addMSecs(diffMSecs * (i - start));
            qDebug() << "Time [" << i << "]:" << fileTime.toString();
            QString fileName = scheme.arg(i, digits, 10, QChar('0'));
            
            layer->setFileName(fileTime, fileName);
        }
    }
}
开发者ID:bholst,项目名称:OceanVisServer,代码行数:61,代码来源:ConfigurationParser.cpp


注:本文中的QDateTime::addMSecs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。