aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Models/LastPlayedSortComparer.cs
blob: c5c22fb26fdaa591c6ced17bf4014c1f884c7506 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Ryujinx.Ui.App.Common;
using System;
using System.Collections;

namespace Ryujinx.Ava.Ui.Models
{
    internal class LastPlayedSortComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            string aValue = (x as ApplicationData).LastPlayed;
            string bValue = (y as ApplicationData).LastPlayed;

            if (aValue == "Never")
            {
                aValue = DateTime.UnixEpoch.ToString();
            }

            if (bValue == "Never")
            {
                bValue = DateTime.UnixEpoch.ToString();
            }

            return DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue));
        }
    }
}