mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-10 23:23:52 +01:00
Date/time stored in UTC now.
This commit is contained in:
parent
2c2796f746
commit
ad85713fee
@ -141,9 +141,11 @@ QVariant MessagesModel::data(const QModelIndex &index, int role) const {
|
||||
int index_column = index.column();
|
||||
|
||||
if (index_column == MSG_DB_DCREATED_INDEX) {
|
||||
// This column contains QDateTime.
|
||||
return TextFactory::parseDateTime(QSqlTableModel::data(index,
|
||||
role).toString()).toString(Qt::DefaultLocaleShortDate);
|
||||
// This column contains QDateTime properly stored in ISO format.
|
||||
// So that QDateTime::fromString(...) is okay here.
|
||||
return QDateTime::fromString(QSqlTableModel::data(index,
|
||||
role).toString(),
|
||||
Qt::ISODate).toLocalTime().toString(Qt::DefaultLocaleShortDate);
|
||||
}
|
||||
else if (index_column == MSG_DB_AUTHOR_INDEX) {
|
||||
QString author_name = QSqlTableModel::data(index, role).toString();
|
||||
|
@ -18,7 +18,6 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
|
||||
QString temp;
|
||||
QLocale locale(QLocale::C);
|
||||
QStringList date_patterns;
|
||||
// Dec 1 2013 07:56:46
|
||||
date_patterns << "yyyy-MM-ddTHH:mm:ss" << "MMM dd yyyy hh:mm:ss" <<
|
||||
"MMM d yyyy hh:mm:ss" << "ddd, dd MMM yyyy HH:mm:ss" <<
|
||||
"dd MMM yyyy" << "yyyy-MM-dd HH:mm:ss.z" << "yyyy-MM-dd" <<
|
||||
@ -30,10 +29,13 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
|
||||
temp = date.left(pattern.size());
|
||||
dt = locale.toDateTime(temp, pattern);
|
||||
if (dt.isValid()) {
|
||||
dt.setTimeSpec(Qt::UTC);
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: ISO time zone offsets are not read now, problem.
|
||||
|
||||
// Parsing failed, return invalid datetime.
|
||||
return QDateTime();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user