mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 06:21:19 +12:00
move date comparison code to date class declaration
This commit is contained in:
parent
15f8f87f52
commit
b605b359f4
3 changed files with 35 additions and 42 deletions
|
@ -434,46 +434,6 @@ static inline int order_to_int(const std::weak_ordering &wo)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool operator<(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
const auto& lastA = a.last_played;
|
||||
const auto& lastB = b.last_played;
|
||||
|
||||
if(lastA.year < lastB.year)
|
||||
return true;
|
||||
if(lastA.year > lastB.year)
|
||||
return false;
|
||||
|
||||
// same year
|
||||
if(lastA.month < lastB.month)
|
||||
return true;
|
||||
if(lastA.month > lastB.month)
|
||||
return false;
|
||||
|
||||
// same year and month
|
||||
return lastA.day < lastB.day;
|
||||
}
|
||||
|
||||
static bool operator==(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
const auto& lastA = a.last_played;
|
||||
const auto& lastB = b.last_played;
|
||||
|
||||
return lastA.year == lastB.year &&
|
||||
lastA.month == lastB.month &&
|
||||
lastA.day == lastB.day;
|
||||
}
|
||||
|
||||
static std::weak_ordering operator<=>(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
if (a == b)
|
||||
return std::weak_ordering::equivalent;
|
||||
if (a < b)
|
||||
return std::weak_ordering::less;
|
||||
else
|
||||
return std::weak_ordering::greater;
|
||||
}
|
||||
|
||||
std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, SortData* sortData)
|
||||
{
|
||||
auto titleLastPlayed = [](uint64_t id)
|
||||
|
@ -508,7 +468,7 @@ std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2,
|
|||
return std::tie(isFavoriteB, nameA) <=> std::tie(isFavoriteA, nameB);
|
||||
}
|
||||
case ColumnGameStarted:
|
||||
return titleLastPlayed(titleId1) <=> titleLastPlayed(titleId2);
|
||||
return titleLastPlayed(titleId1).last_played <=> titleLastPlayed(titleId2).last_played;
|
||||
case ColumnGameTime:
|
||||
return titlePlayMinutes(titleId1) <=> titlePlayMinutes(titleId2);
|
||||
case ColumnRegion:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue