1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-19 16:42:01 +00:00
Ryujinx/Ryujinx.Ava/UI/Models/Generic/LastPlayedSortComparer.cs
Emmanuel Hansen 02714a1291
Avalonia - Add source generator for locale items (#3999)
* Add source generator for locale keys

* use locale keys in Ui subdir
2023-01-03 19:45:08 +01:00

33 lines
No EOL
997 B
C#

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[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));
}
}
}