mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-04-27 09:20:50 -07:00
* 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
32 lines
848 B
C#
32 lines
848 B
C#
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)
|
|
{
|
|
var aValue = x.LastPlayed;
|
|
var bValue = y.LastPlayed;
|
|
|
|
if (!aValue.HasValue)
|
|
{
|
|
aValue = DateTime.UnixEpoch;
|
|
}
|
|
|
|
if (!bValue.HasValue)
|
|
{
|
|
bValue = DateTime.UnixEpoch;
|
|
}
|
|
|
|
return (IsAscending ? 1 : -1) * DateTime.Compare(bValue.Value, aValue.Value);
|
|
}
|
|
}
|
|
} |