Hello,
I can parse "31 Jan 2009" by the code:
Code:
But the same code cannot parse a date with february like "01 Feb 2009" . What is the problem with Feb?
Printable View
Hello,
I can parse "31 Jan 2009" by the code:
Code:
But the same code cannot parse a date with february like "01 Feb 2009" . What is the problem with Feb?
try
If you produce the output with QDate::toString(), just use the same format both times.
If you use no format for toString(), use none for fromString().
To your problem:
where does your input come from?
In case it is user input: Perhaps you have a loc ale set that happens to have "Jan" for january but something different from "Feb" for february?
(check by printing qDebug() << date.toString() )
HTH
Actually I am parsing an email header like:
Code:
.... Date: Sun, 1 Feb 2009 18:51:32 +0200 Message-ID: <c56e0c650902010851u7edd6c83p3a86fc07a9b6957b@mail.gmail.com> Subject: konux119 From: george wi <yrtgs@gmail.com> To: Pr Test1 <prtest1@ford.com.tr> Content-Type: multipart/alternative; boundary=0016364571aa18aff90461de40d2 X-TM-AS-Product-Ver: IMSS-7.0.0.3127-5.5.0.1026-16438.00 X-TM-AS-Result: No-2.664-4.5-31-1 .......
I grab the "Date:.." part, clean unnecessary things...
I put day to day(in number format), month to month(that is character format), year to year..The actual code is:
Code:
QString dayremoved; QStringList datelist; dayremoved= dateHeader.section(",",1,1); datelist = dayremoved.split(" ");
also didn't work?
note that "dd" expects leading zeros (01, 02, ...) whereas "d" does not (1, 2, ...).
Yes you've go it :) It works now...!
Correct me if I'm wrong but this is basically the Qt::TextDate format, isn't it?
yes it is...
So why not simply use: ? The only possible problem is the time zone at the end of the string.
I've a similar problem. I need to convert 24-10-1977 (and 24/10/1977) to 1977-10-24
I've tried with:
QString fdate = value.value<QString>();
QDate qdate = QDate::fromString(fdate,"dd-mm-yyyy");
qDebug() << qdate.toString(Qt::ISODate);
the last row output is null.
It doesn't work. Any idea?
what will you get if you do this?
Code:
.... qDebug() << qicssmtpmailer; ....
solve. The correct line is:
QDate qdate = QDate::fromString(fdate,"d-M-yyyy");