PDA

View Full Version : Upper case in QDateTime !!!!



paranoid_android
12th March 2006, 23:20
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:



QFileInfo dInfo(*getFile()); //getFile() returns a pointer to a file I've created
QDateTime dDate(dInfo.created());
QString format("ddd, dd MMM yyyy hh:mm:ss");
QString httpDate(dDate.toTimeSpec(Qt::UTC).toString());
httpDate += " GMT";


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!!:confused:

jacek
12th March 2006, 23:55
Where do you use that format variable?

paranoid_android
13th March 2006, 08:56
Sorry.I removed that because it does not work and i forgot to readd it to the code.The code is:




QFileInfo dInfo(*getFile()); //getFile() returns a pointer to a file I've createdQDateTime dDate(dInfo.created());
QString format("ddd, dd MMM yyyy hh:mm:ss");
QString httpDate(dDate.toTimeSpec(Qt::UTC).toString(format ));
httpDate += " GMT";

jacek
13th March 2006, 15:25
QDateTime::toString() is locale dependent. Try this:
QLocale locale( QLocale::C );
QDateTime utcDate = dDate.toTimeSpec( Qt::UTC );
httpDate += locale.toString( utcDate.date(), "ddd, dd MMM yyyy" );
httpDate += utcDate.toString( " hh:mm:ss GMT" );

paranoid_android
15th March 2006, 08:38
It works. Thank you!!!!:)