From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:22:00 +0200 Subject: Move solution and projects to src --- .../UI/Models/Generic/LastPlayedSortComparer.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs (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 new file mode 100644 index 00000000..98caceb5 --- /dev/null +++ b/src/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 + { + 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[LocaleKeys.Never]) + { + aValue = DateTime.UnixEpoch.ToString(); + } + + if (bValue == LocaleManager.Instance[LocaleKeys.Never]) + { + bValue = DateTime.UnixEpoch.ToString(); + } + + return (IsAscending ? 1 : -1) * DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue)); + } + } +} \ No newline at end of file -- cgit v1.2.3