Results 1 to 5 of 5

Thread: Upper case in QDateTime !!!!

  1. #1
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Upper case in QDateTime !!!!

    Hi.I will try to explain the problem with my poor knowledge of english.

    I've to use "If unmodified since" in a http header and according to RFC 1123 the format must be something like "Sun, 12 Mar 2006 10:00:00 GMT".

    So i do:

    Qt Code:
    1. QFileInfo dInfo(*getFile()); //getFile() returns a pointer to a file I've created
    2. QDateTime dDate(dInfo.created());
    3. QString format("ddd, dd MMM yyyy hh:mm:ss");
    4. QString httpDate(dDate.toTimeSpec(Qt::UTC).toString());
    5. httpDate += " GMT";
    To copy to clipboard, switch view to plain text mode 

    and I get something like "sun, 12 mar 2006 10:00:00 GMT" even if in the Assistant I read that "ddd" should produce Sun with the upperCase and not with LowerCase and the same thing for MMM.
    Is there anyone that knows why i get "day" instead of "Day"? because the request does not work with lower cases.Thanks!!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Upper case in QDateTime !!!!

    Where do you use that format variable?

  3. #3
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Upper case in QDateTime !!!!

    Sorry.I removed that because it does not work and i forgot to readd it to the code.The code is:

    Qt Code:
    1. QFileInfo dInfo(*getFile()); //getFile() returns a pointer to a file I've createdQDateTime dDate(dInfo.created());
    2. QString format("ddd, dd MMM yyyy hh:mm:ss");
    3. QString httpDate(dDate.toTimeSpec(Qt::UTC).toString(format));
    4. httpDate += " GMT";
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Upper case in QDateTime !!!!

    QDateTime::toString() is locale dependent. Try this:
    Qt Code:
    1. QLocale locale( QLocale::C );
    2. QDateTime utcDate = dDate.toTimeSpec( Qt::UTC );
    3. httpDate += locale.toString( utcDate.date(), "ddd, dd MMM yyyy" );
    4. httpDate += utcDate.toString( " hh:mm:ss GMT" );
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Upper case in QDateTime !!!!

    It works. Thank you!!!!

Similar Threads

  1. upper case input
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2006, 09:44

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.