Results 1 to 2 of 2

Thread: Bug in 'yy' matching?

  1. #1
    Join Date
    Dec 2012
    Posts
    1
    Platforms
    Windows

    Default Bug in 'yy' matching?

    I'm having an issue with the 'yy' matcher (but not the 'yyyy' matcher) on QDateTime. The code fragment is Python (using PyQt bindings for the Qt application framework), but I assume you can manage any needed translation since the strings and calls are basically the same. FYI the u prefix on u'text' simply forces Python strings to use unicode. Here's my test code:

    Qt Code:
    1. from PyQt4.QtGui import *
    2. from PyQt4.QtCore import *
    3.  
    4. date_works_text = u'Monday, 23 April 2012 22:51:41'
    5. date_works_pattern = u'dddd, d MMMM yyyy hh:mm:ss'
    6.  
    7. date_broken_text = u'Monday, 23 April 12 22:51:41'
    8. date_broken_pattern = u'dddd, d MMMM yy hh:mm:ss'
    9.  
    10. date_works = QDateTime.fromString(date_works_text, date_works_pattern)
    11. date_broken = QDateTime.fromString(date_broken_text, date_broken_pattern)
    12.  
    13. print date_works.toString()
    14. print date_broken.toString()
    To copy to clipboard, switch view to plain text mode 

    The output on my system is:

    Qt Code:
    1. D:\Users\...>qDateTimeTest.py
    2. Mon Apr 23 22:51:41 2012
    3. <blank line where the second toString() should be>
    To copy to clipboard, switch view to plain text mode 

    It appears to dislike a 'yy' match on '12' even though the pattern is included in the QDateTime format (http://qt-project.org/doc/qt-4.8/qda...tml#fromString)

    Am I doing something wrong? If not, can someone confirm that this is a Qt issue (versus PyQt) issue? If you can't reproduce it in Qt, I'll check with the PyQt folks. This just seemed like the right place to start since the alternate 'yyyy' works fine.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Bug in 'yy' matching?

    I get the same problem in Qt using v4.6.something (c++, not python)
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Matching Data from QStringList
    By prophet0 in forum Qt Programming
    Replies: 3
    Last Post: 31st March 2012, 07:52
  2. qobject::tr() matching problem
    By proeber in forum Qt Programming
    Replies: 0
    Last Post: 22nd September 2011, 20:39
  3. about no matching function for call to
    By Alain Delon in forum General Programming
    Replies: 1
    Last Post: 5th March 2011, 22:30
  4. QRegExp not matching the { character !!
    By gontham in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 01:20
  5. pattern [image] matching
    By rachana in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2007, 14:31

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.