aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Gtk3/UI/Helper/SortHelper.cs
blob: 3e3fbeaae5cb22c0559a8c5f463500cdf4280a72 (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
28
29
30
31
32
33
using Gtk;
using Ryujinx.UI.Common.Helper;
using System;

namespace Ryujinx.UI.Helper
{
    static class SortHelper
    {
        public static int TimePlayedSort(ITreeModel model, TreeIter a, TreeIter b)
        {
            TimeSpan aTimeSpan = ValueFormatUtils.ParseTimeSpan(model.GetValue(a, 5).ToString());
            TimeSpan bTimeSpan = ValueFormatUtils.ParseTimeSpan(model.GetValue(b, 5).ToString());

            return TimeSpan.Compare(aTimeSpan, bTimeSpan);
        }

        public static int LastPlayedSort(ITreeModel model, TreeIter a, TreeIter b)
        {
            DateTime aDateTime = ValueFormatUtils.ParseDateTime(model.GetValue(a, 6).ToString());
            DateTime bDateTime = ValueFormatUtils.ParseDateTime(model.GetValue(b, 6).ToString());

            return DateTime.Compare(aDateTime, bDateTime);
        }

        public static int FileSizeSort(ITreeModel model, TreeIter a, TreeIter b)
        {
            long aSize = ValueFormatUtils.ParseFileSize(model.GetValue(a, 8).ToString());
            long bSize = ValueFormatUtils.ParseFileSize(model.GetValue(b, 8).ToString());

            return aSize.CompareTo(bSize);
        }
    }
}