Results 1 to 8 of 8

Thread: QT 5.2 bug of incorrect calling of QDateTime::fromString() ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2016
    Posts
    13
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT 5.2 bug of incorrect calling of QDateTime::fromString() ?

    Quote Originally Posted by Lesiok View Post
    This code does exactly what to do. Format string does not contain expressions for milliseconds. Try this :
    Qt Code:
    1. const QString format = "yyyy-MM-dd hh:mm:ss.zzz";
    To copy to clipboard, switch view to plain text mode 
    I have added milliseconds to the format string, but resulting qdatetime is still invalid !))
    Debug output is normal.
    So I suppose that there is the bug in my Qt or Qt Creator release.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 5.2 bug of incorrect calling of QDateTime::fromString() ?

    What does it mean "is still invalid" ? d2.isValid() returns false or You see somewhere different value than you expect ?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT 5.2 bug of incorrect calling of QDateTime::fromString() ?

    I've changed the second output to
    Qt Code:
    1. qDebug() << "d2=" << d2 << ", d2.isValid=" << d2.isValid();
    To copy to clipboard, switch view to plain text mode 
    and the output is
    Qt Code:
    1. d2= QDateTime(2016-09-05 12:25:39.000 CEST Qt::TimeSpec(LocalTime)) , d2.isValid= true
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 5.2 bug of incorrect calling of QDateTime::fromString() ?

    So change it to :
    Qt Code:
    1. qDebug() << "d2=" << d2.toString(format) << ", d2.isValid=" << d2.isValid();
    To copy to clipboard, switch view to plain text mode 
    P.S.
    Look at qdatetime.cpp how operator << for qdebug is working for this class.
    In Qt 4.8 it uses QDateTime::toString() for this, in 5.7 QDateTime::toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")).
    So this is not a bug.
    Last edited by Lesiok; 5th September 2016 at 12:23.

Similar Threads

  1. Incorrect Julian Day
    By Rayven in forum Qt Programming
    Replies: 6
    Last Post: 16th November 2011, 13:10
  2. QMake Incorrect Makefile generated
    By Octal in forum Qt Tools
    Replies: 7
    Last Post: 19th March 2011, 15:05
  3. Incorrect position of QPushButton on mac
    By francis in forum Qt Programming
    Replies: 4
    Last Post: 1st March 2011, 17:34
  4. QDateTime fromString
    By mklieber in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2008, 21:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.