diff options
Diffstat (limited to 'Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs')
-rw-r--r-- | Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs b/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs new file mode 100644 index 00000000..b322ed64 --- /dev/null +++ b/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs @@ -0,0 +1,33 @@ +using Ryujinx.Ava.Common.Locale; +using Ryujinx.Ui.App.Common; +using System; +using System.Collections.Generic; + +namespace Ryujinx.Ava.UI.Models.Generic +{ + internal class LastPlayedSortComparer : IComparer<ApplicationData> + { + public LastPlayedSortComparer() { } + public LastPlayedSortComparer(bool isAscending) { IsAscending = isAscending; } + + public bool IsAscending { get; } + + public int Compare(ApplicationData x, ApplicationData y) + { + string aValue = x.LastPlayed; + string bValue = y.LastPlayed; + + if (aValue == LocaleManager.Instance["Never"]) + { + aValue = DateTime.UnixEpoch.ToString(); + } + + if (bValue == LocaleManager.Instance["Never"]) + { + bValue = DateTime.UnixEpoch.ToString(); + } + + return (IsAscending ? 1 : -1) * DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue)); + } + } +}
\ No newline at end of file |