Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77081

QDateTime成员函数addSecs存在缺陷

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.6.2
    • Core: Date/Time
    • win10 X64
    • Windows

    Description

      QDateTime m_timeStart = QDateTime::currentDateTime();
      QDateTime m_timeEnd = m_timeStart.addSecs(60);
      qDebug() << "m_timeStart0" << m_timeStart;
      qDebug() << "m_timeEnd000" << m_timeEnd;

      uint ts = m_timeEnd.toTime_t() - m_timeStart.toTime_t();

      m_timeStart = m_timeEnd.addSecs(-ts * 2 );

      qDebug() << "m_timeStart1" << m_timeStart;
      qDebug() << "m_timeEnd111" << m_timeEnd << "\n";

       

      最后一次打印出来的m_timeStart 时间并不是期望的值,说明在m_timeEnd.addSecs(-ts * 2 );时候出现错误,打印结果如下:

      m_timeStart0 QDateTime(2019-07-17 18:32:57.340 中国标准时间 Qt::TimeSpec(LocalTime))
      m_timeEnd000 QDateTime(2019-07-17 18:33:57.340 中国标准时间 Qt::TimeSpec(LocalTime))
      m_timeStart1 QDateTime(2155-08-24 01:00:13.340 中国标准时间 Qt::TimeSpec(LocalTime))
      m_timeEnd111 QDateTime(2019-07-17 18:33:57.340 中国标准时间 Qt::TimeSpec(LocalTime))

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Eddy Edward Welbourne
            bingliu liu bing
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes