aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx/Ui/Helper/SortHelper.cs
blob: c7a72ab9b0fa10b7caa889714b230e3dbe30d662 (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);
        }
    }
}