02-07-2013 05:09 PM
I'm using a ListView that displays an RSS feed. How can I get it to show in order by date? The format is "Thu, 07 Feb 2013 18:58:00 GMT". I think by default it would have them come in with the newest first (how I want it) but it has some form of SORTING enabled that cunks it by alphabetical order with days.
So for example it will show an order of entries by something like...
Thu, 07 Feb 2013 14:14:00 GMT
Thu, 07 Feb 2013 18:58:00 GMT
Tues, 05 Feb 2013 12:45:00 GMT
Wed, 06 Feb 2013 12:22:00 GMT
Wed, 06 Feb 2013 15:52:00 GMT
But see, it's ordering them by day, not full date, day, and time together. Can I remove this sorting?
02-10-2013 04:37 AM
You can convert the date string from the RSS feed to a QDateTime object, and then convert it to seconds using toTime_t()
I use that in one of my apps, and it looks something like this:
QString creationDate = values["creationDate"].toString(); creationDate.resize(creationDate.size() - 6); // removes timezone data from my string. You may need to do the same QDateTime takenTime = QDateTime::fromString(creationDate, "yyyy-MM-ddThh:mm:ss"); values["creationDate"] = takenTime.toTime_t();
As yo can see, I replaced the original date value with the new value in seconds, as I had no need for the original, but you could insert the converted seconds, use that to sort ascending or decending, and keep the original if you want to display the date to the users.