SaveState Manager: Format specially close dates
This commit is contained in:
@@ -664,11 +664,24 @@ namespace gui
|
|||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString format_datetime(const QDateTime& date, const QString& fmt)
|
QString format_datetime(const QDateTime& date, const QString& fmt, bool is_relative, const QString& fmt_relative)
|
||||||
|
{
|
||||||
|
const qint64 exctrated_date = date.date().toJulianDay();
|
||||||
|
const qint64 current_date = QDate::currentDate().toJulianDay();
|
||||||
|
|
||||||
|
if (!is_relative || exctrated_date > current_date || current_date - exctrated_date >= 3)
|
||||||
{
|
{
|
||||||
return date.toString(fmt);
|
return date.toString(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_date == exctrated_date)
|
||||||
|
{
|
||||||
|
return QString("Today %1").arg(date.toString(fmt_relative));
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("%1 days ago %2").arg(current_date - exctrated_date).arg(date.toString(fmt_relative));
|
||||||
|
}
|
||||||
|
|
||||||
QString format_timestamp(s64 time, const QString& fmt)
|
QString format_timestamp(s64 time, const QString& fmt)
|
||||||
{
|
{
|
||||||
return format_datetime(datetime(time), fmt);
|
return format_datetime(datetime(time), fmt);
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace gui
|
|||||||
QDateTime datetime(s64 time);
|
QDateTime datetime(s64 time);
|
||||||
|
|
||||||
// Convert a QDateTime to a readable string
|
// Convert a QDateTime to a readable string
|
||||||
QString format_datetime(const QDateTime& date, const QString& fmt = "yyyy-MM-dd HH:mm:ss");
|
QString format_datetime(const QDateTime& date, const QString& fmt = "yyyy-MM-dd HH:mm:ss", bool is_relative = false, const QString& fmt_relative = "HH:mm:ss");
|
||||||
|
|
||||||
// Convert a timestamp to a readable string
|
// Convert a timestamp to a readable string
|
||||||
QString format_timestamp(s64 time, const QString& fmt = "yyyy-MM-dd HH:mm:ss");
|
QString format_timestamp(s64 time, const QString& fmt = "yyyy-MM-dd HH:mm:ss");
|
||||||
|
|||||||
@@ -686,7 +686,7 @@ void savestate_manager_dialog::PopulateSavestateTable()
|
|||||||
const savestate_data& savestate = savestates[i];
|
const savestate_data& savestate = savestates[i];
|
||||||
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::name), new custom_table_widget_item(savestate.name));
|
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::name), new custom_table_widget_item(savestate.name));
|
||||||
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::compatible), new custom_table_widget_item(savestate.is_compatible ? tr("Compatible") : tr("Not compatible"), Qt::UserRole, savestate.is_compatible));
|
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::compatible), new custom_table_widget_item(savestate.is_compatible ? tr("Compatible") : tr("Not compatible"), Qt::UserRole, savestate.is_compatible));
|
||||||
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::date), new custom_table_widget_item(gui::utils::format_datetime(savestate.date), Qt::UserRole, savestate.date));
|
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::date), new custom_table_widget_item(gui::utils::format_datetime(savestate.date, "yyyy-MM-dd HH:mm", true, "HH:mm"), Qt::UserRole, savestate.date));
|
||||||
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::path), new custom_table_widget_item(savestate.path));
|
m_savestate_table->setItem(i, static_cast<int>(gui::savestate_list_columns::path), new custom_table_widget_item(savestate.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user