From 531da8a1c0760c8ebf121ac83ba4c840ead9e443 Mon Sep 17 00:00:00 2001 From: SamusAranX Date: Fri, 12 May 2023 01:56:37 +0200 Subject: Changed LastPlayed field from string to nullable DateTime (#4861) * Changed LastPlayed field from string to nullable DateTime Added ApplicationData.LastPlayedString property Added NullableDateTimeConverter for the DateTime->string conversion in Avalonia * Added migration from string-based last_played to DateTime-based last_played_utc * Updated comment style * Added MarkupExtension to NullableDateTimeConverter and changed its usage Cleaned up leftover usings * Missed one comment --- .../UI/Models/Generic/LastPlayedSortComparer.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/Ryujinx.Ava/UI/Models/Generic') diff --git a/src/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs b/src/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs index 98caceb5..3627ada9 100644 --- a/src/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs +++ b/src/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs @@ -1,4 +1,3 @@ -using Ryujinx.Ava.Common.Locale; using Ryujinx.Ui.App.Common; using System; using System.Collections.Generic; @@ -14,20 +13,20 @@ namespace Ryujinx.Ava.UI.Models.Generic public int Compare(ApplicationData x, ApplicationData y) { - string aValue = x.LastPlayed; - string bValue = y.LastPlayed; + var aValue = x.LastPlayed; + var bValue = y.LastPlayed; - if (aValue == LocaleManager.Instance[LocaleKeys.Never]) + if (!aValue.HasValue) { - aValue = DateTime.UnixEpoch.ToString(); + aValue = DateTime.UnixEpoch; } - if (bValue == LocaleManager.Instance[LocaleKeys.Never]) + if (!bValue.HasValue) { - bValue = DateTime.UnixEpoch.ToString(); + bValue = DateTime.UnixEpoch; } - return (IsAscending ? 1 : -1) * DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue)); + return (IsAscending ? 1 : -1) * DateTime.Compare(bValue.Value, aValue.Value); } } } \ No newline at end of file -- cgit v1.2.3